我有一个带.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的实现是什么?
答案 0 :(得分:1)
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