Compare 2 arrays with find()
10 ビュー (過去 30 日間)
古いコメントを表示
I have 2 arrays:
x = 1:1:3;
Points = [1 3 2 1 1 3 4];
I would like to use find() function comparing each element of 'Points' array with full 'x' array.
It would be similar to do:
find(Points(1) == x)
find(Points(2) == x)
... one by one, but I would like to do it at once without looping. However I get error if I do:
find(Points == x)
0 件のコメント
採用された回答
Star Strider
2019 年 8 月 5 日
x = 1:1:3;
Points = [1 3 2 1 1 3 4];
[~,Out] = ismember(Points, x)
producing:
Out =
1 3 2 1 1 3 0
Experiment with it to get the result you want.
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!