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);
精彩评论