Group a Array Elements

20 ビュー (過去 30 日間)
Hamidreza Rafat
Hamidreza Rafat 2018 年 4 月 4 日
回答済み: KSSV 2018 年 4 月 4 日
X=[1 2 3 3 3 1]
index 1 -> 1 index 2 -> 2 index 3 -> 3 index 4 -> 3 index 5 -> 5 index 6 -> 1
y=[{1,6},{2},{3,4,5}]
How create matrix y?

採用された回答

KSSV
KSSV 2018 年 4 月 4 日
X=[1 2 3 3 3 1] ;
[c,ia,ib] = unique(X) ;
iwant = cell(length(c),1) ;
for i = 1:length(c)
iwant{i} = find(ib==i) ;
iwant{i}
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by