MATLAB: Looping through several files with the same name

for loop

Hello,
I have the following code to load a number of files with the same name
for i = 1:20
fileName = ['flow' num2str(i)];
load(fileName);
end
All files are the same size (100 * 48). For each file I would like to do the following (i've used {filename} to indicate where the file is being used)
{filename} = rad2deg({filename}); % convert all data to degrees
data = zeros(100, 48); % create an empty array to store data
for g = 1:100
for t = 1:48
data(g, t) = ({filename}(g, t)-nanmean({filename}...(g,:)))/nanstd({filename}(g, :)); % convert all data to Z score
end;
end;
I've tried to use
file = (flow(num2str(i)));
but, for some reason this returns a weird array of numbers
I'm pretty new to MatLab so any help will be greatly appreciated!
Many thanks

Best Answer

So here's a solution to your original question
data=zeros(100,48,20); %data from all 20 files
for i = 1:20
fileName = ['flow' num2str(i)];
S=load(fileName);
thisslice = S.(filename).';
thisslice=thisslice-nanmean(thisslice(:));
thisslice=bsxfun(@rdivide,thisslice,nanstd(thisslice,0,2));
data(:,:,i)=thisslice;
end