0
我在Matlab中有兩條線的幾何點數據。我將它們導出到另一個程序,通過這些程序創建樣條。它會計算樣條曲線隨機點的溫度值,併發送回Matlab。查找哪個線點屬於 - 對應的矩陣排序
現在我有這個數據,我不知道溫度屬於哪條線。但我確實得到了新點的座標。所以我需要確定點屬於哪一行,然後使用該信息將溫度向量分成兩部分。
以下是生成「示例」的代碼。
% Known geometric point data which is read by 3rd program.
x1 = 0:0.05:1; y1 = -sin(x1.*(4.*pi))./6;
x2 = 0:0.05:1; y2 = sin(x2.*(pi));
% 3rd program makes spline from given points.
xx1 = 0:0.075:1; xx2 = [0:0.1:1];
yy1 = spline(x1,y1,xx1);
yy2 = spline(x2,y2,xx2);
XY = [xx1, xx2; yy1, yy2];
[Y,I]=sort(XY(1,:));
% The program gives me DAT file with the 'new' coordinates of the new
% points. But the line-up of the points are random. In this example I've
% merged the coordinates of the two lines mixed them by sorting the X
% coordinates.
% The program gives me, for example, the temperature at these points in
% same order as the new coordinates. But now I'll need to know which line
% they belong to.
COORDINATE = XY(:,I);
TEMPERATURE = [COORDINATE(1,:); rand(1,length(COORDINATE))];
目標:
- 確定哪個座標的點屬於[X1,Y1]或[X2,Y2]。
- 拆分TEMPERATURE爲[xx1; T1]和[xx2; T2]相當於#1。
請注意,兩條線不會互相交叉。但是它們不需要具有相同的x間距。