Array of structures (new)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Max Müller
am 26 Aug. 2014
Beantwortet: Michael Haderlein
am 26 Aug. 2014
I am new to this stuff. If i have an Array of structures like this
for i = 1:10
Data(i).x = i
Data(i).y = rand(1,1)
end
is there a possibility to sort Data.y part and change the related Data.x with it ? And can u pls drop some Links for more Infos about structures? Thanks
0 Kommentare
Akzeptierte Antwort
Michael Haderlein
am 26 Aug. 2014
You can simply sort it and use the second output argument:
[~,ind]=sort([Data.y]);
sData=Data(ind);
As always, there's a lot to read in the help (Matlab/Language Fundamentals/Data Types/Structures).
0 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!