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

8 vues (au cours des 30 derniers jours)
Jeremy
Jeremy le 7 Avr 2013
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 commentaire
Oleg Komarov
Oleg Komarov le 7 Avr 2013
What is the purpose? Splitting arrays is usually not recommended.

Connectez-vous pour commenter.

Réponse acceptée

Iman Ansari
Iman Ansari le 7 Avr 2013
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

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by