How to delete all repeat rows?
I mean all repeat rows, like :
A=
[0 4;
2 4;
0 4;
4 8;
3 4]
How to got new_A=
[2 4;
4 8;
3 4]

 採用された回答

Rik
Rik 2020 年 5 月 19 日
編集済み: Rik 2020 年 5 月 19 日

0 投票

There is probably a more efficient way, but you can use unique() to get all first occurrences. Then you can use the second output to find all removed rows, which you can use as an input to setdiff.
A=[0 4;2 4;0 4;4 8;3 4;0 4];
[B,ind]=unique(A,'stable','rows');
ind=setdiff(1:size(A,1),ind);
B=setdiff(B,A(ind,:),'rows');

4 件のコメント

Wang Jack
Wang Jack 2020 年 5 月 19 日
Yes, I'm looking at the official menu [CIA, is] = unique (a, 'rows')
But I haven't got any clue yet..
Rik
Rik 2020 年 5 月 19 日
I have added example code.
Wang Jack
Wang Jack 2020 年 5 月 22 日
Aaaaaawesome, thanks for the help!
Rik
Rik 2020 年 5 月 22 日
Glad to be of help. If it solved your problem, please consider marking it as accepted answer. If not, feel free to comment with your remaining issues.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2018b

タグ

質問済み:

2020 年 5 月 19 日

コメント済み:

Rik
2020 年 5 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by