I want to save a matfile name optimization with the name Project and add time in addition to the name like Project_20/03/2019.mat. Please how do i do it. I tried this but it didnt work
time = datestr(now, 'yyyy_mm_dd');
filename = sprintf('Optimization_%s.mat',time)
save ('C:\dannyuser\Project',filename,datestr(now))

 채택된 답변

Walter Roberson
Walter Roberson 2019년 3월 21일

1 개 추천

save( fullfile('C:\dannyuser\Project', filename) )
If you want the time to be put in as well as part of the file name, do so as part of that sprintf() you have.

댓글 수: 3

Daniel Boateng
Daniel Boateng 2019년 3월 21일
It worked but the problem now is, it is saving all the variables and fields in my matlab workspace as Optimisation instead of only optimisation variable. Is there any help please
save( fullfile('C:\dannyuser\Project', filename), 'NameOfYourOptimizationVariable')
Daniel Boateng
Daniel Boateng 2019년 3월 21일
it works. Thank you very much

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

질문:

2019년 3월 21일

댓글:

2019년 3월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by