How to sort a struct
173 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Peter Meier
am 23 Jul. 2020
Kommentiert: Stephen23
am 23 Jul. 2020
Is it possible to sort a struct? I want to sort the third column.
0 should be in the first row and the highest value at the end (last row). The other values are not important and should be the same ranking.
Thank you.
2 Kommentare
Akzeptierte Antwort
Mohammad Sami
am 23 Jul. 2020
Bearbeitet: Mohammad Sami
am 23 Jul. 2020
You can try like this.
% a = somestruct;
[~,index] = sortrows([a.Var3].');
a = a(index);
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Structures 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!