Saving matlab results many times using loop

2 views (last 30 days)
Hello everyone,
I am having this problem: I need to input different set of data to my code and save results once for a run for 400 times. The problem is I need to save mat file 400 times with 400 different name, anyone here knows how to do it? I am sure it is pretty simple thing, but I have not been able to do so. I would greatly appreciate your response. I want to reiterate again: problem is to save matlab results 400 times with 400 different names (maybe using idices, but I do not know how to do it) using a loop.
Thank you!

Answers (1)

Kevin Phung
Kevin Phung on 5 Feb 2019
Edited: Kevin Phung on 5 Feb 2019
just do:
my_filenames = {'file1','file2','file3'}
for i = 1:length(my_filenames)
save(my_filenames{i},'someVariable')
end
edit:
you can programmatically create 400 file names, for example:
my_filenames=cell(1,400)
for i = 1:400
cell{i} = ['file' num2str(i)] %file1, file2, file3, etc
end

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!