Matlab: import all .mat files in the folder

demand:

Need to import all mat files in a folder

solution

  1. Use the dir () function to get all the .mat file names in this folder
  2. 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

Published 47 original articles · Like 33 · Visit 310,000+

Guess you like

Origin blog.csdn.net/kaever/article/details/72872755