How do I imread stimuli from a randomised array
조회 수: 8 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Laura Proctor
2011년 4월 18일
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
Laura Proctor
2011년 4월 20일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!