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!