Filter löschen
Filter löschen

sorting inside a struct variable

2 Ansichten (letzte 30 Tage)
ramakrishna bathini
ramakrishna bathini am 28 Okt. 2011
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');

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 28 Okt. 2011
[sortedareas, areaidx] = sort([stats.Area]);
sorted_struct = stats(areaidx);
  1 Kommentar
ramakrishna bathini
ramakrishna bathini am 28 Okt. 2011
thank you so much...that solved my problem...

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

Community Treasure Hunt

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

Start Hunting!

Translated by