smilingbuddha
smilingbuddha

Reputation: 14670

loading multiple .mat files in MATLAB

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?

Upvotes: 2

Views: 2690

Answers (1)

kol
kol

Reputation: 28728

Use load(filename, '-ascii')

Upvotes: 5

Related Questions