Sort a vector of <1x1 struct>

I have a vector of <1x1 struct> each structure contains an element containing five sequential times. I would like to sort the vector by the first time in each individual <1x1 struct>.
Thanks in advance.

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 5 月 9 日

0 投票

Assuming that the 5 times are a row vector:
[sortedtimes, idx] = sort(min(vertcat(YourStruct.Element),2));
NewStruct = YourStruct(idx);

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

質問済み:

2012 年 5 月 9 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by