I nedd a hand with this

3 次查看(过去 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