How could I save a file under different name?

if true
files = dir('*.csv');
for f = 1:length(files)
file = files(f);
RawData=importdata(file.name,',',4);
MusAct=RawData.data;
title = file.name;
new_title = strrep(title, file.name, file.name+'HoldPCA');
dlmwrite(new_title, mean3tr,'delimiter',',','-append');
end
end
I have files that I modified and I want to save them under different names. For example, if an original file name is 'filename.csv', I want to save it as 'filename_Mean.csv'. I want to save as a file, and then move to the next file.. How could I do this? Could I do this in a loop?

Answers (1)

Use movefile() to rename a file.
Use copyfile() to copy a file.
See the FAQ for code examples about processing files in a loop: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F

Categories

Asked:

on 28 Jun 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!