How can I sort matrices in side structure ?

2 次查看(过去 30 天)
I have structure contains 3 matrices, but the size of second matrix bigger than the first and last one. Please, I would like to sort them in ascending order. I used "sort" and "sortrows" but they are not working. Regards
  1 个评论
Ammar
Ammar 2017-1-14
The structure have just one field which "Data" and explained in the following: size(clust(1).Data,1) = 130 size(clust(2).Data,1) = 250 size(clust(3).Data,1) = 100
And I am looking to sort them in this order: size(clust(1).Data,1) = 100 size(clust(2).Data,1) = 130 size(clust(3).Data,1) = 250
Thanks

请先登录,再进行评论。

采纳的回答

Andrei Bobrov
Andrei Bobrov 2017-1-14
[ii,~] = cellfun(@size,{clust.Data});
[~,jj] = sort(ii);
clust = clust(jj);
  1 个评论
Ammar
Ammar 2017-1-14
Dear Andrei Bobrov, I would like to thank you for this code. It is work. Thanks.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by