How to change mat files in each iteration?

조회 수: 3 (최근 30일)
armin m
armin m 2021년 12월 13일
편집: Stephen23 2021년 12월 14일
Hi. I am writing code which save output in mat file. I wanna it saves mat file that name changes to specific name with date and time of writing.tnx for e.g.:
...
Save doc3.mat matrix Convert to
Save doc3040620211407.mat matrix Which says this file has been creatwd in date 04/06/2021 in time of 14:07. Tnx
  댓글 수: 1
Stephen23
Stephen23 2021년 12월 14일
편집: Stephen23 2021년 12월 14일
Rather than using the completely ambiguous date format shown in your question, you should consider using an unambiguous ISO 860 date format:
which has the the significant benefit that lexicographical order is also chronological order.

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

채택된 답변

Voss
Voss 2021년 12월 14일
You can try this:
file_name = 'doc3.mat';
file_name = [file_name(1:end-4) datestr(now(),'mmddyyyyhhMM') file_name(end-3:end)];
% then save mat file with name file_name
It wasn't clear from your example whether 04/06 means April 6 or 4 June, this command assumes the month is first. To do day first, swap the 'mm' and 'dd'.
  댓글 수: 7
armin m
armin m 2021년 12월 14일
HAhaaaa i thought i can just ask 1 question!!!!!!
Image Analyst
Image Analyst 2021년 12월 14일
Posters with little activity so far, like you, can (I believe) post up to 10 questions per day.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by