MATLAB: Save in nested loop

for loopsave

Hi,
I'm a bit lost concerning saving data in loops. I have a list of data that I need to analyse with several parameters.
list_files2load = dir('*.txt');
files = {list_files2load.name};
m = length(files);
for w=1:m
sprintf('loading file : %s', files{w})
s = load(files{w});
for A:1:2:20
...
for n=1:17
if... <B
if... <A
plot....
saveas(gcf,[files{w}-A-n], 'ai')
end
end
...
save('files{w}-A-n', 'data', 'ASCII')
end
end
my problem is that I would like to save the data inside the loop, something like data-1-1, then data-1-2 and so on until data-20-17, but i have no clues…
I'll appreciate any help!
cheers
n.

Best Answer

for A:1:2:20
for n=1:17
Name = sprintf('%s-%d-%d', files{w}, A, n);
saveas(gcf, Name, 'ai')
save(Name, 'data', 'ASCII')
end
end