Sorting Struct elements in Numerical order
Mostra commenti meno recenti
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 Commento
Stephen23
il 4 Mag 2021
S = dir(..);
S = natsortfiles(S);
Risposta accettata
Più risposte (1)
Md Farhad Mokter
il 6 Giu 2019
Categorie
Scopri di più su Cell Arrays in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!