How to combine repeated same value to a single value or variable

X=[3 5 ; 1 2 ; 5 6 ; 3 5 ] How to make like Y=[3 5; 1 2; 5 6] ie; representing [3 5] for single time rather displaying it twice

回答 (1 件)

Rik
Rik 2018 年 3 月 12 日

1 投票

You can use unique.

3 件のコメント

RAJASEKAR S
RAJASEKAR S 2018 年 3 月 12 日
But this command holds good for matrix values, how to do for array values
James Tursa
James Tursa 2018 年 3 月 12 日
See the 'rows' option.
Rik
Rik 2018 年 3 月 12 日
That is why the link leads you to the 'rows' flag example:
[C,ia,ic] = unique(A(:,1:2),'rows')
In your case:
X=[3 5 ; 1 2 ; 5 6 ; 3 5 ];
Y=unique(X,'rows','stable');

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

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

質問済み:

2018 年 3 月 12 日

コメント済み:

Rik
2018 年 3 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by