loading multiple .mat files in MATLAB

Posted by smilingbuddha on Stack Overflow See other posts from Stack Overflow or by smilingbuddha
Published on 2011-11-20T01:43:55Z Indexed on 2011/11/20 1:51 UTC
Read the original article Hit count: 450

Filed under:

I have 110 files named time1.mat, time2.mat ..., time110.mat. I want to load these matrices into the MATLAB workspace.

I have always used load -'ASCII' matrix.mat to load an ASCII matrix file in the current folder.

So I tried doing

for i=1:10 
    filename=strcat('time',int2str(i),'.mat');
    load -'ASCII' filename
end

But I am getting a MATLAB error as

??? Error using ==> load
    Unable to read file filename: No such file or directory.
?

Of course the string filename seems to be evaluated correctly by MATLAB as time1.mat. in the first iteration where it crashes at the load line.

Any suggestions how I should do this?

© Stack Overflow or respective owner

Related posts about matlab