Create a dated log file in Matlab

If you change your datasets or code a lot in Matlab, it is smart to keep track of the results over time (trust me….). The ‘diary’ function allows you to record all output of your scripts to a file. Append your main .m file with the following code to create a diary/log file that is uniquely dated to the time (to the minute) that you ran the script:

date_now = clock;
date_now = strcat(num2str(date_now(1)),'_',num2str(date_now(2)),'_', num2str(date_now(3)), num2str(date_now(4)), num2str(date_now(5)));
diary(strcat('log', date_now,'.log'));

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Leave a Reply