How do I imread stimuli from a randomised array

8 Ansichten (letzte 30 Tage)
Tom Fredrick
Tom Fredrick am 18 Apr. 2011
I tried reading stimulus image into matlab matrix but get receiving error message saying the file does not exist. Here is my code:
files = dir('D:\picture\*.jpg'); %folder name is stimuli
trial = 0;
nTrial = 10;
for trial=1:nTrial
stimfilename=strcat('D:\picture\',char(tArray(trial,3))) imdata=imread(char(stimfilename));
end
I ran the above code and it returns stimfilename as D:\picture\J123jpg. However, it vomits an error message
??? Error using ==> imread at 372
File "D:\picture\J123jpg" does not exist.
Please any help will be highly appreciated. Thanks in advance.
Tom

Akzeptierte Antwort

Laura Proctor
Laura Proctor am 18 Apr. 2011
You may wish to try by simplifying the code a bit. Try the following lines to see if you still get the same error message.
files = dir('D:\picture\*.jpg'); %folder name is stimuli
for trial=1:length(files)
stimfilename=['D:\picture\',files(trial).name];
imdata=imread(char(stimfilename));
end
  5 Kommentare
Laura Proctor
Laura Proctor am 20 Apr. 2011
The error message shows that the file name is J123jpg, but not J123.jpg as one might expect. Can you go into the directory D:\picture and just try imread('J123.jpg') to see if the image can be read without the other code? If that works, try the following lines:
files = dir('D:\picture\*.jpg');
stimfilename=['D:\picture\',files(1).name]
imdata = imread(stimfilename)
To see if it can read just the first file.
Tom Fredrick
Tom Fredrick am 20 Apr. 2011
Thanks Laura, it's now working. Thanks too Walter. I appreciate your advice.
Cheers,
Tom

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Convert Image Type 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!

Translated by