構造体配列の並び替え (降順)

添付図のような構造体配列において、フィールドSに対して"降順"で並び替えをし、フィールドP1、P2、P3もそれに対応して行を並び替えたいです。
構造体配列の行を並び替える方法はありますでしょうか。

 Accepted Answer

Akira Agata
Akira Agata on 11 Jan 2021

0 votes

struct2table 関数でいったんテーブル型変数に変換して、sort 関数でソートしたうえで再び table2struct 関数で構造体配列に戻す、という方法ではいかがでしょうか?

1 Comment

ST
ST on 11 Jan 2021
ご回答ありがとうございます。
そちらのやり方で並び替えることができました。

Sign in to comment.

More Answers (0)

Categories

Asked:

ST
on 10 Jan 2021

Commented:

ST
on 11 Jan 2021

Community Treasure Hunt

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

Start Hunting!