MATLAB: Problem with %d in MATLAB

problem with %d in matlab

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, …

Best Answer

for k = 1:22
pic2read = strcat(num2str(k),'.dcm');
if k<10
pic2read = strcat('0',pic2read);
end
imread(pic2read);
end