Sort the dir loaded files
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2019-11-2
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 个评论
更多回答(1 个)
Stephen23
2019-11-2
Download my FEX submission natsortfiles and follow the examples in its documentation:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!