Save in nested loop
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Jan
2011-4-12
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
3 个评论
Jan
2011-4-12
File = 'data.txt'
[FilePath, FileName, FileExt] = fileparts(File)
It is always a reliable method to use absolute file names including the path. See also: help fullfile.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!