From: Israel Johnson on
I would like to read in a series of images with imread, but do not know how to do it. The filenames for the images are of the format 1A.tif, 2A.tif, 3A.tif, etc.

so to read in one file
imread('1A.tif');

and to loop the names of these files
for i = 1:n
eval([num2str(i),'A.tif']);
end

but when I combine these two operations there is confusion with the double apostrophes. Is there another way? Thanks in advance for your help.
From: Dan on
You don't need the "eval".

"Israel Johnson" <mconverse85(a)yahoo.com> wrote in message <huoror$gj4$1(a)fred.mathworks.com>...
> I would like to read in a series of images with imread, but do not know how to do it. The filenames for the images are of the format 1A.tif, 2A.tif, 3A.tif, etc.
>
> so to read in one file
> imread('1A.tif');
>
> and to loop the names of these files
> for i = 1:n
> eval([num2str(i),'A.tif']);
> end
>
> but when I combine these two operations there is confusion with the double apostrophes. Is there another way? Thanks in advance for your help.
From: Walter Roberson on
Israel Johnson wrote:
> I would like to read in a series of images with imread

http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
From: ImageAnalyst on
Use sprintf() to build up your filenames:

folder = 'c:\MyImagesFolder';
for k = 1 : n
% Get the base file name.
baseFileName = sprintf('%dA.tif', k);
% Combine it with the folder to get the full filename.
fullFileName = fullfile(folder, baseFileName);
% Read the image file into an array.
imageArray = imread(fullFileName);
% Display the image.
subplot(10,10,k);
imshow(imageArray);
end
From: Steven Lord on

"Walter Roberson" <roberson(a)hushmail.com> wrote in message
news:huote6$fs6$2(a)canopus.cc.umanitoba.ca...
> Israel Johnson wrote:
>> I would like to read in a series of images with imread
>
> http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F

Actually, Q4.10 in the FAQ (which discusses processing a series of files)
seems more applicable.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com