Creating log of matlab run script with time and date
조회 수: 6 (최근 30일)
이전 댓글 표시
i want to create log file with date and time. could you please help me how to write time and date information into log file.
댓글 수: 0
채택된 답변
Jan
2018년 6월 4일
FileName = fullfile(tempdir, 'MyLogFile.txt');
Message = 'Hello';
fid = fopen(FileName, 'a');
if fid == -1
error('Cannot open file: %s', FileName);
end
fprintf(fid, '%s: %s', datestr(now, 0), Message);
fclose(fid);
See doc datestr for other formats.
With a modern Matlab version:
fprintf(fid, '%s: %s', datetime, Message);
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!