How can I create a log of all the commands run by my MATLAB files?
11 views (last 30 days)
Show older comments
I am having problems locating the source of a problem with my program. I want to create a log file to show me what my program was doing at the time of the failure.
Accepted Answer
MathWorks Support Team
on 18 Jan 2010
There are a couple MATLAB functions which will be helpful for determining where the crash is occurring in your code. These functions are DIARY and ECHO. The DIARY command logs all output to the command window into a file. The ECHO command echos commands from your MATLAB files to the command window.
To enable the highest level of logging execute the following commands before running your program:
echo on
echo on all
diary crashlog.txt
When the program finishes execution you can turn off the logging with the command:
diary off
The file crashlog.txt will contain all commands run by your program and any output displayed to the command window. If MATLAB crashes, the log will be abruptly terminated at the point where the crash occurred. Please note, the ECHO command will cause your application to run more slowly. Also, if your application runs for a long time, this may result in a very large log file. The diary command will continue to append to an existing file, so you may want to periodically delete this file. If you are not using any function files you can eliminate the command "echo on all" or if you only want to enable logging for only some function files you can enable echoing for only certain functions. For more information on these functions you can execute the following commands at the MATLAB prompt:
doc diary
doc echo
0 Comments
More Answers (0)
See Also
Categories
Find more on Entering Commands in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!