How to identify the repeated elements in an array and delete those rows?
2 ビュー (過去 30 日間)
古いコメントを表示
I have a matrix array like this:
1 100
2 200
3 200
4 200
5 500
And I want to identify the repeated elements on the right column, and delete the entire row of the matrix, to get something like this:
1 100
2 200
5 500
How can I do that?
0 件のコメント
回答 (2 件)
the cyclist
2023 年 4 月 9 日
編集済み: the cyclist
2023 年 4 月 9 日
Here is one way:
M = [1 100;
2 200;
3 200;
4 200;
5 500];
[~,j] = unique(M(:,2));
out = M(j,:)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Multidimensional Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!