How do I make a loop for multiple identical actions?
Ältere Kommentare anzeigen
I need to read some images in matlab like:
>> A1=dicomread('IM-0001.dcm');
>> A2=dicomread('IM-0002.dcm');
>> A3=dicomread('IM-0003.dcm');
>> A4=dicomread('IM-0004.dcm');
>> A5=dicomread('IM-0005.dcm');
I have 180 of those images. Is there a way to do it automatically so the first image is stored as A1 and the last as A180?
Cheers.
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 11 Sep. 2012
0 Stimmen
3 Kommentare
Tomislav
am 11 Sep. 2012
Sean de Wolski
am 11 Sep. 2012
Preallocate img as a cell array or 3d array (3d array only if all images the same size)
Then:
img = cell(170,1);
for ii = 1:170
img{ii} = dicomread(['C:\Users\Tomek\Documents\MATLAB\dicoms\IM-0002-' num2str(ii,'%04i') '.dcm'])
end
Now each element of img is the corresponding image:
imshow(img{120})
Kategorien
Mehr zu Images finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!