Split array in sub arrays according to growing value in first row

4 ビュー (過去 30 日間)
Jeremy
Jeremy 2013 年 4 月 7 日
I have an array where the first row has growing intiger numbers. How can I split the array according to those values.
Example: This
[ 1 1 1 2 3 3
x x x x x x
y y y y y y ]
Should become something like this
[ [1 1 1 [2 [3 3
x x x x x x
y y y] y] y y] ]
  1 件のコメント
Oleg Komarov
Oleg Komarov 2013 年 4 月 7 日
What is the purpose? Splitting arrays is usually not recommended.

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

採用された回答

Iman Ansari
Iman Ansari 2013 年 4 月 7 日
Hi
m=[1 1 1 2 3 3;randi(10,2,6)];
c={};
for i=min(m(1,:)):max(m(1,:))
c{i}=m(:,m(1,:)==i);
end
  1 件のコメント
Jeremy
Jeremy 2013 年 4 月 9 日
編集済み: Jeremy 2013 年 4 月 9 日
Thanks, it works.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by