0

I have a set of files in a folder. the file names are listed as : Month_1, Month_2, .... I want to get the data through a loop that i don't have to change the file name every single time. I tried for example:

for (i=1:1:53)
    path(i) = strcat('C:\Users\Desktop\Diagramm\','\Month_', i);
    aa=xlsread(path(i));
    ...
end;  

but it isn't working. I would appreciate any help.

Hase
  • 11
  • 3

2 Answers2

0

Suppose your files are located in the outdir.

files=dir(outdir);

for i=1:size(files,1)
   % do stuff with files(i)
end
stone stone
  • 75
  • 2
  • 10
0
files=dir('*.xls');
for i=length(files(:,1))
    aa=xlsread(files(i).name);
    % If you want to store data from each file separately with a new name
    eval(sprintf('Month%d=data ;',i));
end
madbitloman
  • 816
  • 2
  • 13
  • 21