save in a new file using 'save' command

조회 수: 7 (최근 30일)
aditi
aditi 2020년 8월 8일
댓글: aditi 2020년 8월 8일
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
Stephen23
Stephen23 2020년 8월 8일
편집: Stephen23 2020년 8월 8일
aditi
aditi 2020년 8월 8일
Thanks for your reply. Could you please explain a little bit. I am somewhat new to MATLAB SO it will be really helpful.

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2020년 8월 8일
편집: Stephen23 2020년 8월 8일
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(fullfile(D,'outfile'),'01','.mat');
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
aditi
aditi 2020년 8월 8일
Thank you so much.. It solved my problem.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by