how to compare 3 matrix
1 回表示 (過去 30 日間)
古いコメントを表示
Hi
I got 3 matrixes, each different vertical dimension (mx3,nx3,px3). What I need to do is to compare first and second column in all 3 matrixes. If first and second data in a row match in all 3 matrixes, than i have to extract that in new matrix. How I do that.
Here are examples of matrixes:
A=[1 22 501;1 23 224;2 15 6;2 13 221;2 6 14; 3 2 10; 3 12 50];
B=[1 22 5;1 26 33;2 14 10;2 15 13;2 6 14; 3 2 166; 3 12 60; 4 7 12];
C=[1 2 14;1 22 15;2 23 6;2 15 20;2 6 14; 3 2 11; 3 5 100; 3 12 0; 4 7 12;]
The result must come:
D=[1 22; 2 15; 2 6;3 2;3 12]
Thank you very much in advance. Nejc
0 件のコメント
採用された回答
Azzi Abdelmalek
2013 年 3 月 22 日
編集済み: Azzi Abdelmalek
2013 年 3 月 22 日
a=A(:,1:2)
D=a(ismember(a,B(:,1:2),'rows') & ismember(a,C(:,1:2),'rows') ,:)
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!