How can I sort matrices in side structure ?

4 Ansichten (letzte 30 Tage)
Ammar
Ammar am 14 Jan. 2017
Kommentiert: Ammar am 14 Jan. 2017
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 Kommentar
Ammar
Ammar am 14 Jan. 2017
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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by