MATLAB Answers


Diary and logfile are empty until I close them: how to fix this?

Asked by Paolo Bocchini on 21 Jan 2011
Latest activity Commented on by Eric Zhang on 23 Jul 2016
I use the -logfile option and the diary command to track the progresses of my codes. In fact, sometimes during the runs (that take days) MATLAB graphical interface freezes and the only way to check the progress is to look at the output in the command window. However, I realized that the most recent versions (2009+) write the logfile and the diary only when the file is finally closed. While the file is still open, it is just a 0kb empty file. For the diary, I solved adding commands
diary; diary;
that close and reopen the diary, so it is written down, but for the logfile there is no solution.
Is there anybody that can help?
Besides, if anybody can tell me a procedure to "unfreeze" the user interface without aborting the computation, it would be great! (I use WinXP and Win7).

  1 Comment

Having the same problem here. Didn't expect such a straightforward demand to be so hard to meet.

Sign in to comment.



1 Answer

Answer by Doug Hull on 21 Jan 2011

If you have long running programs like this, I would want to be more explicit about the saving of data in the middle and creating of log files. This will give you greater control over what is put in the file, and when it is saved.
Also, for long running code, have you considered using sendmail.m to send periodic updates? What about some of the File Exchange entries that allow you to tweet from MATLAB? Both of these can be useful for remote monitoring of long term runs.

  1 Comment

Thank you for the suggestions, I really appreciate them.
However, they do not address my question.
In the latest versions, Matlab's logfile (the one created with "matlab.exe -logfile") is actually written only when Matlab is closed.
Similarly, the output of the "diary" command is actually written only when the diary is turned off.
Is there a way to change this behavior?
Thank you again!

Sign in to comment.