delete row if in column 1 nad 2 are the same values

1 回表示 (過去 30 日間)
UWM
UWM 2019 年 9 月 30 日
コメント済み: UWM 2019 年 9 月 30 日
Hello. I have e.g. 3 x 5 matrix.
I want to delete all rows which have the same elements in column 1 and 2.
For instance: a = [2,7,1; 3,4,2; 3,7,5; 2,2,4; 6,6,9] => [2,7,1; 3,4,2; 3,7,5]
In this case, as in row 4 was repeated 2 in column 1 nad 2 and in column 5 was repeated 6 in column 1 nad 2, both rows are removed.
Thanks in advance.

採用された回答

Walter Roberson
Walter Roberson 2019 年 9 月 30 日
a(a(:,1)==a(:,2), :) = [];
  1 件のコメント
UWM
UWM 2019 年 9 月 30 日
Works perfectly, thanks :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by