demand:
Need to import all mat files in a folder
solution
- Use the dir () function to get all the .mat file names in this folder
- Use for loop to loop all file names of load ()
Examples
Read all the mat files in this folder 'I: \ learn \ EE \ task1 \ T = 50', and read out the vol1 and vol2 fields
prefix=('I:\learn\EE\task1\T=50\');
d=dir([prefix,'*.mat']);
for i=1:length(d)
t(i)=load([prefix,d(i).name],'vol1','vol2') ;
end