Array of structures (new)

조회 수: 1 (최근 30일)
Max Müller
Max Müller 2014년 8월 26일
답변: Michael Haderlein 2014년 8월 26일
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

채택된 답변

Michael Haderlein
Michael Haderlein 2014년 8월 26일
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개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by