我将简要解释代码背后的想法,然后深入研究我的问题。
我正在收集数据,其中前两列是长坐标和纬度坐标,第三列是 gps 信号强度。
我将有两个矩阵,每个矩阵对应不同的卫星。使用第一个矩阵的 x,y 坐标,我使用第二个矩阵的 TriScatteredInterp 函数对信号强度进行了插值(反之亦然)。我的想法是我将为各个位置创建可能的信号强度并获得某种超级德劳内三角测量。
到目前为止,我已经设法完成了所有这些工作。(感谢您在这一点上容忍我)。
我现在要做的是将两个矩阵(由插值数据组成)组合成一个矩阵。如果 long 和 lat 坐标相同,即第一列和第二列中的前两个值与另一个矩阵中的相同,我想将信号强度添加到行中,添加到第四列中。如果 lat 和 long 值不同,我希望在我的新矩阵中创建一个新行并添加数据。我已经编辑了问题并在问题的末尾附上了所需的答案。(-为清楚起见,编辑了本节)
我非常困惑,并希望您能提供任何帮助。我已经广泛搜索了有用的信息,但我很不幸。
由于我有很多问题,这是最复杂的,我不确定是否要发布所有问题。我决定只发布一个,如果有人让我知道提出更多问题的礼仪,我将不胜感激;我是新来的。
感谢您阅读我冗长的问题,我很抱歉我无法使其更简洁。
感谢您提供的任何帮助。山姆
x = [1, 3, 5, 2, 4, 5, 3, 1, 2, 3, 4, 5; %I wanteed to make an array that kind of made sense
1, 1, 1, 2, 2, 3, 3, 3, 4, 5, 3, 4; %Using random values became kind of difficult
20, 40, 10, 50, 80, 60, 80, 40, 50, 50, 70, 20]';
y = [0, 2, 4, 1, 2.5, 4, 2, 0, 1, 2, 3, 4;
2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 4, 5;
10, 30, 20, 40, 70, 80, 90, 30, 60, 40, 80, 20]';
dt1 = DelaunayTri(x(:,1), x(:,2)); %This makes the dt for the x array
dt2 = DelaunayTri(y(:,1), y(:,2));
interp1 = TriScatteredInterp(x(:,1), x(:,2), x(:,3)); %I can use the dt to do this as below
interp2 = TriScatteredInterp(dt2, y(:,3)); %use the dt array here like so
newValuesforY = interp1(y(:,1), y(:,2)); %This line uses the interpretation function of the DT for x, to predict values at the y co-ords that I enter.
yNew = [y newSSforY];
newSSforX = interp2(x(:,1), x(:,2));
xNew = [x newSSforX];
xNew(:,[3,4])=xNew(:,[4,3]); %I swap these around for clarity
%I now wish to merge the two, as mentioned in the above post.
我添加了我想要的答案:
0 2 10 NaN
0 4 30 NaN
1 1 NaN 20
1 3 40 40
1 5 60 NaN
2 2 30 50
2 4 90 50
2 5 40 NaN
2.5 4 70 57.5
3 1 NaN 40
3 3 52.5 80
3 4 80 65
3 5 30 50
4 2 20 80
4 3 50 70
4 4 80 46.66666667
4 5 20 NaN
5 1 NaN 10
5 3 NaN 60
5 4 NaN 20
由此,我丢弃了经纬度相同的重复数据,然后将两个数组newSSforY和newSSforX合并为一个数组。