开发者

sort .mat format file based on two fields in MATLAB

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜