% 读取后 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); fori = 1:len file_name{i}=namelist(i).name; x= load(file_name{i}); end
批量保存 .mat 文件
使用 save命令,可以批量保存文件。
例如,已知矩阵 A,将 A 矩阵的每一列进行拆分,分别保存在 1-points.mat, 2-points.mat, 3-points.mat 中,代码如下:
1 2 3 4 5 6 7
A=[0.7329-0.000019.2805; -0.00000.732925.0947] fori=1:3 chr=[num2str(i),'-points.mat'] b=A(:,i) save(chr,'b') end