I nedd a hand with this

조회 수: 1 (최근 30일)
Jules Ray
Jules Ray 2011년 10월 12일
Hi dear colleages... i`m fixing a script in matlab and i'm stucked in a really simple but confusing dilema.
Ok this is the problem:
I got two tables of different sizes, the first one "A" is composed by 3 columns, x, y and z, and 16 rows. THe second one "B" is formed by two columns, x and y and 6 rows.
The question is i need to obtain a final an output table fomed by 3 columns x,y,z composed by elements under the condition of:
1) element equals to the pair X,Y founded in table B, wich are present in table "A". 2) include also the third value Z (Table A) for items selected under the condition 1 3) Do not considers NaN present in both tables
Table A:
X Y Z 21 23 1 21 24 1 22 23 2 20 21 6 34 12 8 28 26 9 24 21 5 NaN NaN NaN 21 22 2 30 22 4 29 21 5 22 28 6 32 27 5 30 25 1 25 25 2 28 25 6 23 29 4
Table B
X Y Z 21 23 22 22 22 28 34 12 28 25 25 25
Requested answer:
21 23 1 22 28 6 34 12 8 28 25 6 25 25 2
thanx a lot... for any suggestion
PS: and if somebodie search for scripts for topographic analysis contact me

채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 10월 12일
out = A(ismember(A(:,1:2),B,'rows'),:)
OR
[lo1,loc] = ismember(A(:,1:2),B,'rows');
out = A(lo1,:);
[ignore,idx] = sort(loc(lo1));
out = out(idx,:);

추가 답변 (1개)

Jules Ray
Jules Ray 2011년 10월 13일
you are the best andrei... thanx a lot

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by