Save in nested loop
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Jan
el 12 de Abr. de 2011
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 comentarios
Jan
el 12 de Abr. de 2011
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Type Conversion en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!