Command History
View previously run statements
Description
The Command History displays a log of statements that you ran in the current and previous MATLAB® sessions. The Command History lists the date and time of each session in the short date format for your operating system, followed by the statements from that session. Brackets in the left margin indicate statements that were processed as a group. A red mark precedes each group of statements that generated an error.
You can select entries in the Command History and then perform these actions for the selected entries.
Action | How to Perform the Action |
---|---|
Create a script from statements. | Select an entry or entries, and then right-click and select Create Script or Create Live Script from the context menu. The Editor or Live Editor opens a new file that contains the statements you selected from the Command History. |
Rerun previous statements. | Do one of the following:
To extend the selection to include multiple statements, press Shift+↑. |
Copy statements to another window. | Select an entry or entries, and then do one of the following:
|
Create a favorite command from statements. | Select an entry or entries, and then right-click and select Create New Favorite. The Favorite Commands Editor opens with the selected entries added to the Code field. Configure the other fields and click Save. For more information about favorite commands, see Rerun Favorite Commands. |
Delete entries. | Select the entries to delete, and then right-click and select Delete, or press the Delete key. To delete all entries, click the actions button and select Clear Command History from the context menu. You cannot recall entries deleted in this way. |
Open the Command History
You can view the Command History in a pop-up window off of the Command Window or docked in the Command History panel.
Pop-up window – To view all the history, press the up arrow key (↑) in the Command Window. To view a specific statement, type any part of the statement at the prompt and then press the up arrow key.
The Command History pop-up window closes after you act on a selected statement. You also can close the pop-up window by pressing the Esc key. To disable the pop-up window, go to the Home tab, and in the Environment section, click Layout. Then, in the Layout Options section, clear the Command History > Popup option.
Docked – Click the Command History icon on the sidebar. If the Command History icon is not on a sidebar, click the Open more panels button and select Command History. You also can enter
commandhistory
in the Command Window.
To change how MATLAB searches for results in the Command History, click the actions button in the Command History pop-up window or panel and select from the available options, including Match Anywhere, Match Beginning, and Match Case. For more information about additional settings, see Modify Command History Settings.