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 个评论

Hi,
I found the code that works for this:
[x,idx]=sort([Stimuli.Color]);
Stimuli=Stimuli(idx);
Problem solved:)
-Mikel
Problem solved:)
If so, you should submit it as an answer and Accept-click it.

请先登录,再进行评论。

 采纳的回答

Mikel  Jimenez
Mikel Jimenez 2021-7-21

0 个投票

This code works:
[x,idx]=sort([Stimuli.Color]);
Stimuli=Stimuli(idx);

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by