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 件のコメント
Chris Dan
Chris Dan 2019 年 12 月 26 日
thanks :)

サインインしてコメントする。

その他の回答 (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 Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by