Open Command History window - MATLAB - MathWorks France (2024)

Open Command History window

expand all in page

Description

The Command History window displays a log of statements that you ran in the current and previous MATLAB® sessions. The Command History lists the time and date 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 colored mark precedes each statement that generated an error.

MATLAB saves statements that run in the Command Window to the history file History.xml. These statements include those you run using the Evaluate Selection item on context menus in tools such as the Editor, Command History window, and Help browser. By default, MATLAB automatically saves the command history file after each statement. The history file does not include every action taken in MATLAB. For example, changes to values in the Variables editor are not included in the Command History window. All entries remain until you delete them, or until the number of statements in the history file exceeds the number of statements to save, as specified in the Command History preferences. When the specified limit is reached, MATLAB automatically deletes the oldest entries. By default, the Command History window saves 25,000 statements.

You can select entries in the Command History window, 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 opens a new file that contains the statements you selected from the Command History window.

Rerun previous statements.

Do one of the following:

  • Press the Up Arrow key (↑) until the statement you want appears at the prompt, and then press Enter.

  • Double-click an entry or entries in the Command History window.

  • Select an entry in the Command History window and press Enter.

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:

  • Select Copy from the context menu. Paste the selection into an open file in the Editor or any application.

  • Drag the selection from the Command History window to an open file or another application.

Create a favorite command from statements.

Select an entry or entries, and then do one of the following:

  • Click the Save as favorite command button Open Command History window - MATLAB- MathWorks France (1) to the left of the selection. MATLAB creates a new favorite command in the default Favorite Commands category.

  • Right-click and select Create Favorite. The Favorite Command Editor opens with the selected entries added to the Code field. Configure the desired 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 recall a deleted entry, right-click and select Undo Delete, or press Ctrl+Z.

To delete all entries, click the action button Open Command History window - MATLAB- MathWorks France (2) (or Open Command History window - MATLAB- MathWorks France (3)), and then select Clear Command History from the context menu. You cannot recall entries deleted in this way.

Open Command History window - MATLAB- MathWorks France (5)

Open the Command History

To open the Command History window with all history showing, in the Command Window, press the Up Arrow key (↑) or enter commandhistory. To open the Command History window and display a specific statement, type any part of the statement at the prompt and then press the Up Arrow key. To change how MATLAB searches for results, click the action button Open Command History window - MATLAB- MathWorks France (6) (or Open Command History window - MATLAB- MathWorks France (7)) and select from the available options including Match Anywhere, Match Beginning, and Match Case.

By default, the Command History window closes after a statement is selected or the Esc key is pressed. To keep the Command History window open, in the Command History window, click the action button Open Command History window - MATLAB- MathWorks France (8) and then select either Detach or Dock. If the Command History window is closed while detached or docked, go to the Home tab, and in the Environment section, click Layout. Then, under Show, click Command History and select either Docked or Popup.

In MATLAB Online™, the Command History window displays in the left sidebar by default. To show or hide the Command History window, click the Command History icon Open Command History window - MATLAB- MathWorks France (9) in the sidebar. To remove the Command History from the sidebar, go to the Home tab, and in the Environment section, click Layout. Then, under Layout Options, click Command History and clear the Docked option.

Examples

expand all

Use the Command History search feature to find and run previous plot statements.

In the Command Window, run these statements to create two line plots.

x = 0:pi/100:2*pi;y = sin(x);plot(x,y)x1 = linspace(-2*pi,2*pi);y1 = sin(x1);y2 = cos(x1);figureplot(x1,y1,x1,y2)

Type plot and then press the up-arrow key. MATLAB displays the Command History with all instances of plot highlighted. The last run instance of plot is selected.

Open Command History window - MATLAB- MathWorks France (10)

Press the up-arrow key to select the previous run instance of plot and press Enter. MATLAB runs the statement plot(x,y).

Open Command History window - MATLAB- MathWorks France (11)

Programmatic Use

expand all

commandhistory opens the MATLAB Command History window when it is closed, and selects the Command History window when it is open.

Version History

Introduced before R2006a

See Also

diary | Command Window

Topics

  • Set Command History Preferences
  • Change Desktop Layout

Commande MATLAB

Vous avez cliqué sur un lien qui correspond à cette commande MATLAB:

 

Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.

Open Command History window - MATLAB- MathWorks France (12)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

Contact your local office

Open Command History window - MATLAB
- MathWorks France (2024)
Top Articles
Latest Posts
Article information

Author: Geoffrey Lueilwitz

Last Updated:

Views: 5645

Rating: 5 / 5 (80 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Geoffrey Lueilwitz

Birthday: 1997-03-23

Address: 74183 Thomas Course, Port Micheal, OK 55446-1529

Phone: +13408645881558

Job: Global Representative

Hobby: Sailing, Vehicle restoration, Rowing, Ghost hunting, Scrapbooking, Rugby, Board sports

Introduction: My name is Geoffrey Lueilwitz, I am a zealous, encouraging, sparkling, enchanting, graceful, faithful, nice person who loves writing and wants to share my knowledge and understanding with you.