how do i sort cell array
27 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
andrew
le 18 Oct 2013
Réponse apportée : Andrei Bobrov
le 18 Oct 2013
I was wondering how can I sort a cell array. I have a cell array that contains 'T1-001'to 'T1-058' and 'T2-001 to T2-058' and was wondering if I could sort it so that it can go something like this:
T1-001,T2-001,T1-002, T2-002, etc.
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 18 Oct 2013
If a is your cell array
b=reshape(a,numel(a)/2,2)'
out=b(:)
0 commentaires
Plus de réponses (2)
Andrei Bobrov
le 18 Oct 2013
q = {'T1-001','T2-058','T1-235','T1-058','T2-001',' T1-045'};
q0 = regexp(q,'\d*','match');
q1 = str2double(cat(1,q0{:}));
[~,ii] = sortrows(q1,[2 1]);
out = q(ii);
0 commentaires
Voir également
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!