我有一个包含 .mat 文件的文件夹,我想编写一个循环来加载这些文件并对数据执行一些操作:
1)选择我的数据文件文件夹
2)执行以下一组操作(伪代码):
for i = 1:99
load 'Data0i.mat' ('Datai.mat', if i > 9);
data = data * 10;
save data as 'Data0i.mat' to another folder;
end;
什么是 MATLAB 实现?
inputFolder = 'infolder';
outputFolder = 'outfolder';
for i = 1:99
%# Load data
inputFilename = sprintf('%s/%02d.mat', inputFolder, i);
load(inputFilename)
%# Process data
data = data * 10;
%# Savedata
outputFilename = sprintf('%s/%02d.mat', outputFolder, i);
save(outputFilename, 'data')
end