How to remove all the rows if first two columns has same number?
2 ビュー (過去 30 日間)
古いコメントを表示
I have matrix like this. I wants to remove the all the rows which contain same numbers in first two columns
1 1 1 200 2
1 2 2 200 2
1 3 3 200 2
1 4 4 200 2
2 1 1 200 2
2 2 2 200 2
2 3 3 200 2
2 4 4 200 2
3 1 1 200 2
3 2 2 200 2
3 3 3 200 2
3 4 4 200 2
4 1 1 200 2
4 2 2 200 2
4 3 3 200 2
4 4 4 200 2
for example
1 2 2 200 2
1 3 3 200 2
1 4 4 200 2
2 1 1 200 2
2 3 3 200 2
2 4 4 200 2
3 1 1 200 2
3 2 2 200 2
3 4 4 200 2
4 1 1 200 2
4 2 2 200 2
4 3 3 200 2
0 件のコメント
採用された回答
Guillaume
2019 年 7 月 12 日
Two of many possible ways:
yourmatrix(diff(yourmatrix(:, [1 2]), [], 2) == 0 , :) = [];
yourmatrix(yourmatrix(:, 1) == yourmatrix(:, 2), :) = [];
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Portfolio Optimization and Asset Allocation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!