필터 지우기
필터 지우기

Trying to save a Matlab file with a timestamp

조회 수: 48 (최근 30일)
Peter Carchia
Peter Carchia 2021년 4월 9일
댓글: Stephen23 2021년 4월 9일
Hello, I am writing up a code that is producing a basic projectile motion graph. I want each graph to be saved to a folder on my desktop where each file is saved under a timestamp from when it was created. I am new and not sure if this is too challenging. Can anyone help or offer suggestions. Thanks

채택된 답변

KSSV
KSSV 2021년 4월 9일
for i = 1:10
data = rand(100,1) ;
fname = strcat('projjectile',string(datetime('now','Format',"yyyy-MM-dd-HH-mm-ss")),'.mat') ;
save(fname,'data')
end
  댓글 수: 1
Stephen23
Stephen23 2021년 4월 9일
For clarity and efficiency (no superfluous type conversions), prefer sprintf over string concatenation:
sprintf('projjectile_%s.mat',datetime('now','Format',"yyyy-MM-dd-HH-mm-ss"))
ans = 'projjectile_2021-04-09-03-53-22.mat'

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by