主要内容

命令历史记录Window

打开命令历史记录窗口

描述

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历史记录。这些陈述包括您使用的陈述评估选择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. Some actions are not available inMATLAB Online™

Action

如何执行动作

从语句创建脚本。

选择一个条目或条目,然后右键单击并选择Create Script或者Create Live Script从反面text menu. The Editor opens a new file that contains the statements you selected from the Command History window.

重新运行以前的语句。

做以下一个:

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

  • 双击命令历史记录窗口中的条目或条目。

  • Select an entry in the Command History window and pressEnter

To extend the selection to include multiple statements, pressShift+↑.

复制statements to another window.

选择一个条目或条目,然后执行以下操作之一:

  • Select复制从反面text menu. Paste the selection into an open file in the Editor or any application.

  • 将选择从命令历史记录窗口拖到打开文件或其他应用程序。

从语句创建一个喜欢的命令。

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

  • 点击选择左侧的图标。MATLAB在默认值中创建一个新的喜欢的命令Favorite Commands类别。

  • 右键单击并选择Create Favorite。最喜欢的命令编辑器打开,所选条目添加到Codefield. Configure the desired fields and click节省

有关喜欢命令的更多信息,请参阅Rerun Favorite Commands

删除entries.

选择要删除的条目,然后右键单击并选择删除,或按删除key. To recall a deleted entry, right-click and selectUndo Delete, or pressCtrl+Z

To delete all entries, click(orinMATLAB Online), and then select清晰的命令历史记录从反面text menu. You cannot recall entries deleted in this way.

打开命令历史记录窗口

To open the Command History window with all history showing, in the Command Window, press the Up Arrow key (↑) or entercommandhistory。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(orinMATLAB Online)并从可用选项中进行选择,包括在任何地方匹配,Match Beginning, 和Match Case

默认情况下,命令历史记录窗口选择了语句或Esc键按下键。要保持命令历史记录窗口打开,在命令历史记录窗口中,单击and then select eitherDetach或者Dock。如果命令历史记录窗口在分离或停靠时关闭,请转到Hometab, and in the环境section, clickLayout。Then, under节目, 点击命令历史记录and select eitherDocked或者Popup

To keep the Command History window open inMATLAB Online, go to theHometab, and in the环境section, clickLayout。Then, under节目, 点击命令历史记录and selectDocked

例子

expand all

使用命令历史记录搜索功能查找并运行以前plot语句。

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); figure plot(x1,y1,x1,y2)

类型plotand then press the up-arrow key. MATLAB displays the Command History with all instances ofplothighlighted. The last run instance ofplot被选中。

按向上箭头键选择先前的运行实例plotand pressEnter。MATLAB runs the statement情节(x,y)

Programmatic Use

expand all

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

在R2006a之前引入