this_scan = uint16(dicomread(slices));
ct_scans(1:size(this_scan,1), 1:size(this_scan,2), scan) = this_scan;
This will put the 512 x 512 into the upper left corner, zero padded. If you happen to encounter a file that is larger than the original size, then the ct_scans array would be extended with zero padding.
Some people would instead imresize() to a consistent size. However, that can distort aspect ratios, and can blur edges.
It is questionable as to whether the smaller scans belong at the upper left of the larger scans. imresize() is not always the right answer either. Sometimes the right answer is to do image registration, to find regions of correspondance even though there might be rescaling or rotation or localized distoration.