How can I strip duplicates?

2 ビュー (過去 30 日間)
Holm Roeser
Holm Roeser 2021 年 4 月 8 日
編集済み: per isakson 2021 年 10 月 13 日
I wish to remove all duplicate rows based off of the first column. That is, I want to just strip the excess away. I am struggling to understand how to implement "unique" here. Thanks in advance
  5 件のコメント
Cris LaPierre
Cris LaPierre 2021 年 4 月 9 日
Ah, got it. Thanks.
per isakson
per isakson 2021 年 10 月 13 日
編集済み: per isakson 2021 年 10 月 13 日
The values in the first column are not whole numbers. Thus uniquetol is appropriate.

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

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2021 年 4 月 9 日
If you want
  1. remove duplicates only based on values in the first column
  2. Do not want the returned values be sorted
then you need to do this
in=[[5;5;5;4;4;4;3;3;3;1],(1:10)'];
[~, index]=unique(in(:,1),'stable');
out=in(index,:)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by