Sorting Struct elements in Numerical order
Mostrar comentarios más antiguos
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 comentario
Stephen23
el 4 de Mayo de 2021
S = dir(..);
S = natsortfiles(S);
Respuesta aceptada
Más respuestas (1)
Md Farhad Mokter
el 6 de Jun. de 2019
Categorías
Más información sobre Cell Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!