话不多说,直接贴代码
%%
clear
clc
%% 读取文件
namelist = dir('1\*.mat');
% 读取后namelist 的格式为
% name -- filename
% date -- modification date
% bytes -- number of bytes allocated to the file
% isdir -- 1 if name is a directory and 0 if not
len = length(namelist);
for i = 1:len
file_name=namelist(i).name;
filepath = fullfile(namelist(i).folder, file_name); % 获取文件路径
load(filepath);
end