Matlab how do I sort my data?

I am trying to sort mydata:

mydata = 

  Columns 1 through 3

  [11512x2 double]    [17330x2 double]    [15044x2 double] 

I want to sort it (ascending order) by length(mydata(1)), length(mydata(2)) and length(mydata(3)),

so, after the sorting I have to get:

mydata = 

  Columns 1 through 3

  [11512x2 double]     [15044x2 double]     [17330x2 double]

If it was a struct, I could do:

[blah, order] = sort([mydata(:).Area],'ascend');

and then:

sortedStruct = mydata(order);
mydata = sortedStruct;

but it doesn't..

Answers


You can generate the length vector , sort it and use the index:

  l = cellfun(@length ,mydata);
  [unused,order] = sort(l);
  sortedStruct = mydata(order);

Need Your Help

sIFR and jQuery: dynamically replacing text

jquery sifr

I have a problem. I would like to update a counter (seen by the user as it's displayed in a certain div) when a button is pressed. So this happens when the button is pressed: