Merging Arrays in a Struct and Sorting them

조회 수: 3 (최근 30일)
Chris Dan
Chris Dan 2019년 12월 26일
편집: Stephen23 2019년 12월 26일
Hello, I have a struct like this:
talha4.JPG
I want to join its two arrays into one array and then sort them in ascending order, I am trying this code, but it is not giving me results:
c = [v(1) v(2)]
sort_c = sort(c);

채택된 답변

Bhaskar R
Bhaskar R 2019년 12월 26일
result = sort(struct2array(v), 'ascend')

추가 답변 (1개)

Stephen23
Stephen23 2019년 12월 26일
편집: Stephen23 2019년 12월 26일
A more robust solution, where v is your 2x1 structure:
out = sort([v.IndividualStiffnessMatrix])
Note that your field name is misspelled "Indivual..."

카테고리

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