Sorting Struct elements in Numerical order
Afficher commentaires plus anciens
I have a program which takes some pictures in a struct and performs some pixel counting in each of the pictures. After running the program when I see the struct, the elements are not arranged in the way I want them to be. Here is the code-
img_folder = ('C:\Users\mm\work\blackpixelcount');
filenames = dir(fullfile(img_folder,'*.JPG'));
Total_image = numel(filenames);
for i= 1:Total_image
f = fullfile(img_folder,filenames(i).name);
im= imread(f);
bw= imbinarize(im);
out=nnz(~bw);
get(i)=out;
end
after running the code I see the struct and its sorted as given below-

Now I want the elements to be sorted in numerical ascending order (1,2,3.....9,10,11,12..).
I might be makigs some mistakes there, since I am biggener in matlab. Help will be really appreciated.
1 commentaire
Stephen23
le 4 Mai 2021
S = dir(..);
S = natsortfiles(S);
Réponse acceptée
Plus de réponses (1)
Md Farhad Mokter
le 6 Juin 2019
Catégories
En savoir plus sur Cell Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!