save in a new file using 'save' command

17 visualizaciones (últimos 30 días)
aditi
aditi el 8 de Ag. de 2020
Editada: Stephen23 el 4 de Nov. de 2024 a las 10:53
I have a program which I am applying on 50 files. I want to now save output for everytime I run the program in a new file.
Currently, I am using "save outfile er2 -ascii"
But everytime program runs it replaces outfile with the current output parameters. But I want in a new file i.e. I want a file for every run of program.
Please help me out
  2 comentarios
Stephen23
Stephen23 el 8 de Ag. de 2020
Editada: Stephen23 el 8 de Ag. de 2020
aditi
aditi el 8 de Ag. de 2020
Thanks for your reply. Could you please explain a little bit. I am somewhat new to MATLAB SO it will be really helpful.

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 8 de Ag. de 2020
Editada: Stephen23 el 4 de Nov. de 2024 a las 10:53
If your function is called in a loop then follow the examples here:
If your function is not called in a loop then you could download my FEX submission nextname:
and use it something like this:
D = 'absolute/relative path to the directory where the files are to be saved';
F = nextname(D,'outfile<01>.mat',true);
save(F,'er2')
It will ensure that the filename is unique and unused each time you save the data.
I don't recommend using save for writing text files. For writing text files you should use a more appropriate function:
  1 comentario
aditi
aditi el 8 de Ag. de 2020
Thank you so much.. It solved my problem.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by