sort a structure
2 ビュー (過去 30 日間)
古いコメントを表示
Is it possible to create a structure that holds the following information:
- id_number
- length
such that I can then sort the structure by length from largest to smallest. I then want to retrieve the id_number for the top 5 elements.
0 件のコメント
採用された回答
Daniel Shub
2011 年 9 月 28 日
something like:
s = struct('id_number', mat2cell(1:100, 1, ones(100, 1)), 'length', mat2cell(rand(1, 100), 1, ones(100, 1)));
[a, b] = sort([s.length]);
[s(b(1:5)).id_number]
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Shifting and Sorting Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!