Monday, January 18, 2010

datestr(now) is now

a very simple command to make a timestamp:

>> datestr(now)
ans =
18-Jan-2010 15:31:58

i like to write this string to my output files, especially if it is a file that i append to. then if you change something in the program on some date, you can look at lines before that date to see the difference. (or, if you make 11 versions of the same dumb program, you can always look at the output file and know which version it's from.)

i use these lines a lot to make the first 3 columns of output files. i guess it's overkill to output the date string for every single row/iteration, but whatever.

today = datestr(now);

fprintf(fid, '%s , %s, %d, ', today, filename, i);

the first line goes at the top of my program, and the second one is inside a loop for i.

No comments:

Post a Comment