Hi. I have 11 images in a folder and I want to read and display them. I tried few of ur codes bt the images displayed are nt sorted. plz help me

1 次查看(过去 30 天)
Hi. I have 11 images in a folder and I want to read and display them. I tried few of ur codes bt the images displayed are nt sorted. plz help me

回答(2 个)

Stephen23
Stephen23 2017-4-3
编辑:Stephen23 2021-5-4
Taking a guess that the order should be alphanumeric, in which case you could download my FEX submission natsortfiles which sorts filenames alphanumerically. The submission includes lots of examples, so you should read its documentation carefully:
P = 'C:\Test';
S = dir(fullfile(P,'*.txt'));
S = natsortfiles(S);
for k = 1:numel(S)
F = fullfile(P,S(k).name)
... your code
end

Amruta Talreja
Amruta Talreja 2017-4-4
But there is an error with nat sort that it is undefined function
  1 个评论
Stephen23
Stephen23 2017-4-4
编辑:Stephen23 2017-4-4
Read my answer again: the very first line that I wrote states that you will need to "download my FEX submssion", and I also gave the link:
  1. Click on that link.
  2. Click on the big blue button "Download".
  3. Save the zip file.
  4. Uinzip the zip file into your current directory.
  5. You are now ready to use my FEX submssion natsortfiles.
I did not write that link an d tell you to download the file just for my own entertainment: it is because if you want to use my FEX submission you need to download it. So that is what I told you to do.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Downloads 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by