Try this:
shapes = {'Tri', 'Rec', 'Cir', 'Oct'};
num = 1:20;
% Loop over every shape and every number in "num"
for i = 1 : length(shapes)
for k = 1 : length(num)
thisNumber = num(k); % Extract the number.
% Construct the full file name.
thisFileName = sprintf('%s%d.png', shapes{i}, thisNumber);
fullFileName = fullfile(pwd, thisFileName);
fprintf('Looking for %s\n', fullFileName);
% Check if the file exists.
if exist(fullFileName, 'file')
fprintf(' Found %s\n', thisFileName);
thisImage = imread(file);
% Now do something with thisImage.
else
fprintf(' Did not find %s\n', thisFileName);
end
end
end