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일

0 개 추천

[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개)

카테고리

도움말 센터 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

질문:

2017년 1월 14일

댓글:

2017년 1월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by