compare 2 matrix with different dimensions
古いコメントを表示
Hi, assume that I have a matrix 'info' (800,3), the first column is for ID, the second column is for coordinate x and the last column is for coordinate y. Additionally I have a matrix called 'coordinates'(200,2) where the first column is coordinate x and the second is coordinate y. I want to compare this matrix with the 'info' matrix to find the IDs where the matrix 'coordinates' is equal to the 'info' matrix.
Thanks
1 件のコメント
Walter Roberson
2013 年 6 月 10 日
Are the coordinates integers?
採用された回答
その他の回答 (1 件)
Azzi Abdelmalek
2013 年 6 月 10 日
編集済み: Azzi Abdelmalek
2013 年 6 月 10 日
A=[1 10 20;2 100 200;3 1000 2000;4 44 55]
B=[11 20;100 200;1 4;44 55 ]
out=A(~any(A(:,2:3)-B,2),1)
5 件のコメント
Vanessa
2013 年 6 月 10 日
Angus
2013 年 6 月 10 日
I am wondering does this only output IDs that had matching 'x' values? I am asking as I am interested in how the 'any' function works. Does it only work down one vector?
Azzi Abdelmalek
2013 年 6 月 10 日
Ok, it does not work, look at Walter's answer
Vanessa
2013 年 6 月 11 日
Walter Roberson
2013 年 6 月 11 日
any() by default works along the first dimension (so down columns), but it accepts an optional dimension number. dimension #2 means across rows.
カテゴリ
ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!