sorting inside a struct variable
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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');
0 commentaires
Réponse acceptée
Walter Roberson
le 28 Oct 2011
[sortedareas, areaidx] = sort([stats.Area]);
sorted_struct = stats(areaidx);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!