Newsletters

  • Contact sales

Protecting Your Command History

By Linda Chuss, MathWorks

If you have ever lost your Command History for an entire session due to a system failure, you can avoid this by changing your preferences to save the history throughout the session instead of only at shutdown. By default, MATLAB saves the Command History upon shutdown. If an abnormal termination like a power failure occurs, however, the history is lost. This is especially troublesome if you do not shut down MATLAB daily.

To avoid that problem, select File -> Preferences -> Command History. Set the Saving option to Save after n commands and click OK. For example, set n to 1. MATLAB then saves the history after every line you execute.

If you want a record of system output as well as input, use the diary function. To automatically use the diary for every session, put this function in your startup.m file. Also, consider the logfile startup option for automatically writing output to the specified file. For more information about the Command History and related features, see the online documentation in the Help browser, or follow these links:

  • Command History Preferences , including not saving consecutive duplicate entries to the history
  • The diary function and startup.m file
  • The logfile startup option for Windows and UNIX platforms
  • More about the Command History, including searching the history
cmdhistory_fig1_w.jpg

 

Figure 1: Change preferences to save your Command History after every statement. In the event of a system failure, you will only lose one statement instead of hours, days, or even weeks of history.

Published 2003

Products Used

Learn More

Receive the latest MATLAB and Simulink technical articles.

Related Resources

Latest Blogs