필터 지우기
필터 지우기

How can I sort matrices in side structure ?

조회 수: 2 (최근 30일)
Ammar
Ammar 2017년 1월 14일
댓글: Ammar 2017년 1월 14일
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