Creating log of matlab run script with time and date

7 Ansichten (letzte 30 Tage)
veeraiah boddu
veeraiah boddu am 4 Jun. 2018
Beantwortet: Jan am 4 Jun. 2018
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.

Akzeptierte Antwort

Jan
Jan am 4 Jun. 2018
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);

Weitere Antworten (0)

Kategorien

Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by