开发者

sort .mat format file based on two fields in MATLAB

开发者 https://www.devze.com 2023-01-31 21:03 出处:网络
Please, I have mat format file include structure of array , the structure include many field like ClassNam and DispNo..etc. I would like to sort this file depending on ClassNam then DispNo.. I did sor

Please, I have mat format file include structure of array , the structure include many field like ClassNam and DispNo..etc. I would like to sort this file depending on ClassNam then DispNo.. I did sort the file depending on ClassNam using:

[ClaNa,index] = sort([ SimiMeaGabor50.ClassNam],'ascend');

How can I sort this file depending on two fieldw? ... 开发者_运维问答any one can help me please.

thanks


If you want to sort a structure array S based first on the value in field 'field1' and then on the value in field 'field2', you can use the function SORTROWS as follows:

[sortedData,sortIndex] = sortrows([S.field1; S.field2].',[1 2]);  %'
S = S(sortIndex);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号