How do I avoid intersect overwriting indices?
이전 댓글 표시
Hello,
I'm using intersect function to match some matrices containing distance and pollution data.
I created an array containing all of my distances to work as intersect base. Now I'm trying to find where, in another matrix, my distance is equal to a distance on the set array and grab the pollution information on that line to merge on a resultant column.
The problem is: when i have two coincident distances, the second one overwrite the first one index and sometimes overwrite the pollution data with NaN due to that.
My coding stands like the following:
VETORD(:,1) = (0:0.001:9890);
[k1,i1,j1] = intersect (VETORD,DISTM1);
[k2,i2,j2] = intersect (VETORD,DISTM2);
[k3,i3,j3] = intersect (VETORD,DISTM3);
HAVMAT = VETORD;
HAVMAT(:,2:4) = NaN;
HAVMAT(i1,2) = FINAL(1).MAT(j1,14);
HAVMAT(i2,3) = FINAL(2).MAT(j2,14);
HAVMAT(i3,4) = FINAL(3).MAT(j3,14);
Where VETORD is the main array with all possible distances; DISTM# are the arrays with the calculated distances i'm working and FINAL(#).MAT(:,14) are the pollution data i need merged at the end. Note: I'm building this merged matrix to use pcolor interp plotting (in case it helps)
Thanks in advance for the help
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!