Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Split one column data into 4 arrays
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have an array of 90872x1 double with 4 conditions. As follows:
A=
1
1
1
2
2
2
3
3
4
4
1
1
2
2
3
3
4
4
1
1
1
I want to split the vector into 4 arrays, one per condition. Each column of the new 4 arrays must contain de data of the conditions. Therefore.
A1=
1 1 1
1 1 1
1 1
A2=
2 2
2 2
2
A3=
3 3
3 3
A4=
4 4
4 4
Any help?
3 commentaires
Walter Roberson
le 3 Avr 2019
That creates a cell array, but your question requires a numeric array as output.
Réponses (1)
KSSV
le 3 Avr 2019
A=[1
1
1
2
2
2
3
3
4
4
1
1
2
2
3
3
4
4
1
1
1] ;
C = unique(A) ;
iwant = cell(length(C),1) ;
for i = 1:length(C)
iwant{i} = A(A==C(i)) ;
end
0 commentaires
Cette question est clôturée.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!