Sorting in Matlab

Posted by smichak on Stack Overflow See other posts from Stack Overflow or by smichak
Published on 2010-05-13T15:09:53Z Indexed on 2010/05/13 15:14 UTC
Read the original article Hit count: 182

Filed under:
|
|

Hi,

I would like to sort elements in a comma-separated list. The elements in the list are structs and I would like the list to be sorted according to one of the fields in the struct.

For example, given the following code:

 L = {struct('obs', [1 2 3 4], 'n', 4), struct('obs', [6 7 5 3], 'n', 2)};

I would want to have a way to sort L by the field 'n'. Matlab's sort function only works on matrices or arrays and on lists of strings (not even lists of numbers).

Any ideas on how that may be achieved?

Thanks,

Micha

© Stack Overflow or respective owner

Related posts about matlab

Related posts about sort