MATLAB: How to give a correct file name

cell arraysdigital image processing

I have a 3D face image dataset. I need to load it as a multidimensional array, rows represent diff people and columns represent diff expressions. For my code below, j represent no of people and k represent no of expressions (for an example, i just use 2 people with 4 different expressions each).The images are named from 101 until 104 for the first person, and 201 until 204 for the second one.Then, i need to concatenate the arrays.When i run the code, an error occured saying 'invalid file identifier'. I think the file name(formatSpec) i gave is incorrect. Anyone have an idea?Also, the variable A suppose to be in 3 dimension, but there's no result for it.Thank you.
j=2;
k=4;
mydata = cell(j,k);
%
for p = 1:j
for e = 1:k
people = sprintf('%d%0d.txt' , p);
expression = sprintf('%d%02d.txt' , e);
fname = strcat(people,expression)
fid = fopen(fname);
A = fscanf(fid, '%f %f %f');
mydata{p,e} = A
fclose(fid);
end
end

Best Answer

Replace
people = sprintf('%d%0d.txt' , p);
expression = sprintf('%d%02d.txt' , e);
fname = strcat(people,expression)
by
fname = sprintf('%d%02d.txt', p, e )
which outputs
fname =
204.txt