我將簡要介紹代碼背後的想法,然後深入研究我的問題。基於前兩個值合併兩個數組
我正在收集數據,其中第一個兩個coloumns將長和緯度座標,第三個列將是gps信號強度。
我將有兩個矩陣,每個矩陣對應不同的衛星。使用第一個矩陣的x,y座標,我使用第二個矩陣的TriScatteredInterp函數插值了信號強度(反之亦然)。我的想法是,我將爲各個地點創造可能的信號強度,並獲得某種超級delaunay三角測量。
到目前爲止,我已經完成了所有這些工作。 (感謝您在這一點上與我同在)。
我現在要做的是將兩個矩陣(包括插值數據)組合成一個矩陣。如果長和緯座標相同,即第一列和第二列中的前兩個值與第二列中的相同,我想將行的信號強度添加到第四列中。如果緯度和長度值不同,我希望在我的新矩陣中創建一個新行並添加數據。我已經編輯了這個問題,並在問題結尾附上了期望的答案。 ( - 爲了清晰起見,請仔細閱讀本節)
我絕對不知所措,希望您能給予幫助。我已經非常廣泛地搜索了有用的信息,但我一直不走運。
由於我有一些問題,這是最複雜的,我不確定是否發佈所有問題。我決定發佈一個,並會很感激,如果有人讓我知道提問更多問題的禮節;我是新來的。
謝謝你閱讀我的羅嗦問題,我很抱歉,我不能使它更簡潔。
謝謝你的任何幫助,你可以給。山姆
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組合成一個數組。
謝謝elektrochose,這絕對是輝煌的。我目前離開我的辦公室,所以我無法檢查它是否會返回與我之後的回答相同的數據集(我編輯了它們)。我今晚會回來的。 – broomi 2013-02-25 09:44:44