Help with Sorting cell
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
sc1991
am 4 Jan. 2018
Kommentiert: Stephen23
am 4 Jan. 2018
Hi i have the following cell test
'Apr1'
'Apr10'
'Apr11'
'Apr12'
'Apr13'
'Apr14'
'Apr15'
'Apr17'
'Apr18'
'Apr19'
'Apr20'
'Apr21'
'Apr22'
'Apr23'
'Apr24'
'Apr25'
'Apr29'
'Apr30'
'Apr8'
'Apr9'
can someone tell me how to sort it so that I get the following result
'Apr1'
'Apr8'
'Apr9'
'Apr10'
'Apr11'
'Apr12'
'Apr13'
'Apr14'
'Apr15'
'Apr17'
'Apr18'
'Apr19'
'Apr20'
'Apr21'
'Apr22'
'Apr23'
'Apr24'
'Apr25'
'Apr29'
'Apr30'
0 Kommentare
Akzeptierte Antwort
Stephen23
am 4 Jan. 2018
Bearbeitet: Stephen23
am 4 Jan. 2018
test = natsort(test)
where test is your cell array. You might also be interested in natsortfiles, which is written specifically for sorting filenames and path names.
3 Kommentare
Jan
am 4 Jan. 2018
+1. This is a smart and nice solution. It would be even nicer to avoid the problem by using 'Apr01' instead of 'Apr1': Then sort is sufficient. But this was not part of the question.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!