matlabmatlab-load

How to load .mat file which has a variable filename?


%select all .mat files

oar = dir('*oar.mat'); n = {oar.name};

%loop through files

for l=1:length(oar);

load pat_oar(l) %<---this is the .mat file with variable filename


clear ...

end

How do I write some Matlab script that will read in one .mat file after another...


Solution

  • You file names are stored in n, so you should be able to do:

    for l=1:length(oar)
        load(n{l})
    end