loop for and file nonexistant

조회 수: 2 (최근 30일)
ra chaaba
ra chaaba 2013년 8월 30일
hi,
I have a folder 'Base' that contains 80 images (image 1 is called '1. jpg ', the second is '2. jpg', ............ '80. jpg ') I want to read these images using a loop for.I writethis:
for i = 1:80 imread ('Base \% d.jpg ', i);
but an error stating nonexistent file.
What's the problem. Please help

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 30일
편집: Azzi Abdelmalek 2013년 8월 30일
folder='Base'
for k= 1:80
filename=sprintf('%d.jpg',k)
file=fullfile(folder,filename)
im{k}imread(file);
end
  댓글 수: 1
ra chaaba
ra chaaba 2013년 8월 30일
thank you very much

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2013년 8월 30일
Spacing is important. '%d' not '% d' for example. But a more immediate problem is that imread() must be given a complete file name; it will not construct one like you have shown.

카테고리

Help CenterFile Exchange에서 Denoising and Compression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by