lettura simple

Command History in Matlab

Let me tell you about the command history in Matlab.

It's actually quite simple. All you have to do is type in the command "history".

>> history

You'll get a list of the operations you've typed on the command line, in the order you've typed them.

command history

Now, the list can be quite long, including commands from previous sessions. But don't worry, you can easily narrow it down to the last ten operations by typing history 10

>> history 10

Matlab will display only the latest operations, the ones most recently entered.

latest operations in the command history

By default, Matlab displays a numbered list of commands, which can be a bit cumbersome when you're trying to copy and paste.

But fear not, you can add the "-q" option to get an unnumbered list, which makes it much easier to copy and paste commands.

>> history 10 -q

Alternatively, you can also type history("10","-q")

>> history("10","-q")

In both cases, you'll get the command history without numbering.

the list of the last ten operations

Note. An unnumbered list makes it easier to copy and paste commands. For example, you can copy a sequence of commands and paste them directly into a script or on the command line.

And if you ever need to clear the command history, simply add the "-c" option to the "history" command.

>> history -c

If you want to save the command history to a file, just add the "-w" option and the name of the file you want to save it to.

>> history -w nomefile

Matlab will create a text file containing all the commands in the history.




Report a mistake or post a question




FacebookTwitterLinkedinLinkedin