フィルターのクリア

Sort struct by field name

5 ビュー (過去 30 日間)
Mikel  Jimenez
Mikel Jimenez 2021 年 7 月 21 日
回答済み: Mikel Jimenez 2021 年 7 月 21 日
Hello,
I have the following struct:
I was wondering how to, using some code, reorganize the struct (i.e. sort it) according to the values in the Color field. So, all the blue would be together and then and then all the red. Can't find a clear solution, any help would be very much appreciated.
Thanks,
Mikel
  2 件のコメント
Mikel  Jimenez
Mikel Jimenez 2021 年 7 月 21 日
編集済み: Jan 2021 年 7 月 21 日
Hi,
I found the code that works for this:
[x,idx]=sort([Stimuli.Color]);
Stimuli=Stimuli(idx);
Problem solved:)
-Mikel
Matt J
Matt J 2021 年 7 月 21 日
Problem solved:)
If so, you should submit it as an answer and Accept-click it.

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

採用された回答

Mikel  Jimenez
Mikel Jimenez 2021 年 7 月 21 日
This code works:
[x,idx]=sort([Stimuli.Color]);
Stimuli=Stimuli(idx);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by