Remove repeating variables and replacing them

2 ビュー (過去 30 日間)
AA
AA 2020 年 8 月 22 日
編集済み: Walter Roberson 2020 年 8 月 22 日
Ex: In the array
x=[4 4 5 5 1 2 2 3 3 3 4 5]
, i want to eliminate all repeating elements and retain non-repeating elements
(4, 5,1,2,3,4,5)
i.e., If
x=[4 4 5 5 1 2 2 3 3 3 4 5]
, answer should be
x=[4 5 1 2 3 4 5]

採用された回答

Bruno Luong
Bruno Luong 2020 年 8 月 22 日
x = x([true diff(x)~=0])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by