MATLAB Community

MATLAB, community & more

If You Know Your History, You Can Repeat It

It’s been a long time since we covered the Command History in the Desktop, so I thought I would remind everyone that it’s not just a pretty record of what you’ve done in the command window. You can use the history to selectively re-evaluate your previous commands! One of the ways that I use MATLAB is to try out several commands until I get the sequence that I want. I’ll often iterate through combinations of parameters until the desired output is reached. I’ll then want to group a sequence of correct commands into a reusable set. The Command History is the perfect tool to fit this workflow.

Double-clicking any line in the history will run that command again. You can also drag one or more lines from the history into the Command Window to run them in sequence. Or, instead of running those commands immediately, you can drag them to the editor to add those lines to the open MATLAB-file or drag them to the Shortcuts toolbar to create a new shortcut.

To make selection of multiple commands easier, you can delete intermediary commands from the history, so all that’s left are the commands you’re interested in. Then it’s easy to drag a selection, and you are ready to re-use those commands. You can also use the standard shift-click (or command-click) gestures to select multiple lines.

Finally, you can use the context menu to create a new shortcut, MATLAB file, run those commands, or profile them.

|
  • print

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.