sorting inside a struct variable

조회 수: 2 (최근 30일)
ramakrishna bathini
ramakrishna bathini 2011년 10월 28일
hi,
I have a struct variable containing the centroids,Areas,PixelList..I need to sort the structure with respect to Areas...how can this be achieved this in Matlab...
Previously i sorted a struct variable wrt pixellist..using this code..
CC=bwconncomp(imstack_1434,26);
stats = regionprops(CC,'pixellist');
x=struct2cell(stats);
s=struct('f',x);
b=cellfun(@size,{s.f},'uni',false);
c=cell2mat(b');
[d,index]=sort(c(:,1));
NewS=s(index);
now i m using CC=bwconncomp(imstack_1434,26);
stats = regionprops(CC,'Areas','centroids','pixellist');

채택된 답변

Walter Roberson
Walter Roberson 2011년 10월 28일
[sortedareas, areaidx] = sort([stats.Area]);
sorted_struct = stats(areaidx);
  댓글 수: 1
ramakrishna bathini
ramakrishna bathini 2011년 10월 28일
thank you so much...that solved my problem...

댓글을 달려면 로그인하십시오.

추가 답변 (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