Loop for loading and saving .mat files

前端 未结 1 1577
花落未央
花落未央 2021-01-16 16:55

I have a folder with .mat files, and I want to write a loop for loading these files and doing some actions with data:

1) Choose my folder of data files

2) Pe

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-16 17:30

    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
    

    0 讨论(0)
提交回复
热议问题