I have a group number of array
1) [2 3 2 1] I want [1 2 1 3]
2) [3 3 1 2] I want [1 1 2 3]

 採用された回答

Jonas
Jonas 2022 年 11 月 28 日

1 投票

i think you are searching for this:
[~,~,c]=unique([2 3 2 1],'stable')
c = 4×1
1 2 1 3
[~,~,c]=unique([3 3 1 2],'stable')
c = 4×1
1 1 2 3

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

質問済み:

2022 年 11 月 28 日

回答済み:

2022 年 11 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by