【发布时间】:2017-04-21 14:30:19
【问题描述】:
我在 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 间距。
【问题讨论】: