필터 지우기
필터 지우기

problem with %d in MATLAB

조회 수: 8 (최근 30일)
naila
naila 2013년 8월 1일
Hi all;
I have image file having 01.dcm, 02.dcm, 03.dcm ... 22.dcm;
I want to read all these images with loop. How can I do it Please. I am just confuse with %d command as it can't recognize 01.dcm etc. it is just recognize 1.dcm, 2.dc, ...

채택된 답변

David Sanchez
David Sanchez 2013년 8월 1일
for k = 1:22
pic2read = strcat(num2str(k),'.dcm');
if k<10
pic2read = strcat('0',pic2read);
end
imread(pic2read);
end
  댓글 수: 5
Jan
Jan 2013년 8월 1일
Adding the '0' manually is a really inefficient solution. See Andrei's much nicer and faster sprintf method.

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

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2013년 8월 1일
for k = 1:22, imread(sprintf('%02d.dcm',k)); end
  댓글 수: 1
Jan
Jan 2013년 8월 1일
편집: Jan 2013년 8월 1일
+1. This is compact, direct, fast, not prone to typos.

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

카테고리

Help CenterFile Exchange에서 Historical Contests에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by