Sort the dir loaded files
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Zeynab Mousavikhamene
am 2 Nov. 2019
Beantwortet: Stephen23
am 2 Nov. 2019
I am using
imagefiles = dir(fullfile(d, '*.jpg'));
to get the jpg images in a folder that are named numerically like 1.jpg, 2.jpg, ...
I noticed that they are not loaded with their order like 1.jpg, 2.jpg, 3.jpg, ... and they are just randomly loaded like 1.jpg, 10.jpg, 2.jpg, ...
How can I load them with an order
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 2 Nov. 2019
Construct the file names instead of reading them.
Or construct better file names when you write them -- use leading 0's in the name.
Or look in the File Exchange for "Natural Directory Sort"
0 Kommentare
Weitere Antworten (1)
Stephen23
am 2 Nov. 2019
Download my FEX submission natsortfiles and follow the examples in its documentation:
0 Kommentare
Siehe auch
Kategorien
Mehr zu File Operations 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!