How can I sort valus of a field in struct?

1 回表示 (過去 30 日間)
Mira le
Mira le 2021 年 4 月 30 日
コメント済み: Mira le 2021 年 5 月 1 日
Hello Everyone
I have an issue to sort values so
I have struct named R contains field : sequance [ ]
Cost [ ]
weights (value)
I want to sort R according to weights in ascending order
please help me.
Thank you
  1 件のコメント
Jan
Jan 2021 年 5 月 1 日
Is R a scalar struct or a struct array? Are the contents of the weights field scalars?

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

採用された回答

Jan
Jan 2021 年 5 月 1 日
Maybe:
[~, index] = sort([R.weights]);
sortedR = R(index)
  1 件のコメント
Mira le
Mira le 2021 年 5 月 1 日
R is a struct array;
the content of the weights are scalar

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

タグ

製品


リリース

R2017a

Translated by