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

26 Ansichten (letzte 30 Tage)
ST
ST am 10 Jan. 2021
Kommentiert: ST am 11 Jan. 2021
添付図のような構造体配列において、フィールドSに対して"降順"で並び替えをし、フィールドP1、P2、P3もそれに対応して行を並び替えたいです。
構造体配列の行を並び替える方法はありますでしょうか。

Akzeptierte Antwort

Akira Agata
Akira Agata am 11 Jan. 2021
struct2table 関数でいったんテーブル型変数に変換して、sort 関数でソートしたうえで再び table2struct 関数で構造体配列に戻す、という方法ではいかがでしょうか?
  1 Kommentar
ST
ST am 11 Jan. 2021
ご回答ありがとうございます。
そちらのやり方で並び替えることができました。

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 構造体 finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!