MATLAB: Can I load .mat files in a loop

.mat filefor loop

Hi,
I have 10 files namely img120.mat, img121.mat, img122.mat, img123.mat, img124.mat, img125.mat, img126.mat, img127.mat, img128.mat, img129.mat. RGB values saved in each .mat file.
I would like to load each .mat file, then imshow(RGB) to look at each image. Would it be possible to load all the .mat files in a loop rather than do load img120.mat, imshow(RGB), followed by load 121.mat, imshow(RGB), and so on and so forth…

Best Answer

filenames={'img120','img121',...};
for i=1:numel(filenames)
S=load(filenames{i});
imshow(S.RGB)
end