Merging Arrays in a Struct and Sorting them

4 次查看(过去 30 天)
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