MATLAB: How to create a 3d stack of multiple images in Matlab

3d stack

Can someone help with creating a 3D stack in Matlab. I have used this line of codes, but it seems that my code stacks up the same image as many times as specified.
clear all;
Imatrix = [];
for i=1:500
images{i} = imread(sprintf('0001.tif',i));
Imatrix = cat(3, Imatrix, images{i});
end
I have a folder containing 500 images, and i want to stack the images serially as named.
Thanks

Best Answer

images{i} = imread(sprintf('%04d.tif',i));
Related Question