How to Add Shortcuts to Toolbar

A MATLAB shortcut is an easy way to run a group of MATLAB statements. A shortcut is more convenient than an M-file containing the same statements because it does not have to be in the current directory or on the MATLAB search path when you run it, and you can always easily access it from the Shortcuts toolbar or Start button.

Follow these steps to create and run shortcuts on the desktop Shortcuts toolbar (for more information, use the See Also links at the end of this topic):

  1. Select a statement or group of statements from the Command History window, the Command Window, or an M-file.
  2. Drag the selection to the desktop Shortcuts toolbar, as shown here.

    Image of MATLAB desktop showing three lines selected in the Command History window being dragged to the Shortcuts toolbar to create a new shortcut.

  3. Complete the Shortcut Editor dialog box that appears:
    1. Provide the Label, that is, the name of the shortcut.
    2. The Callback field contains the selected statements, which you can edit as needed. If you copy the statements from the Command Window, prompts (>>) appear in the shortcut, but MATLAB removes the prompts when you save the shortcut.
    3. The Category field is Toolbar Shortcuts, which you must keep so the shortcut appears on the toolbar.
    4. Select an Icon, or choose you own.
    5. Click Save.

      Image of Shortcut Editor dialog box with sample values shown. The sample label is SeaTempStatus. The sample callback consists of three MATLAB statements: format long e, cd d:/mymfiles, and clear; clc.

  4. The shortcut icon and its label appear on the Shortcuts toolbar. Click the item on the toolbar to run the shortcut. This runs the statements in the Callback field of the shortcut.

    Image of Shortcuts toolbar in the MATLAB desktop showing the shortcut just added.

  5. To make changes to the shortcut, right-click the shortcut on the toolbar and select Edit from the context menu.

Start Button Access to Shortcuts

Shortcuts you add to the toolbar are also accessible from the Start button Shortcuts menu in the Toolbar Shortcuts category. You can add shortcuts that do not appear on the toolbar but are accessible from Start -> Shortcuts by choosing a category other than Toolbar Shortcuts when you create or edit the shortcut. You can also run, add, and edit shortcuts via Start -> Shortcuts.

Removing How to Add and What's New Shortcuts

The Shortcuts toolbar includes two shortcuts. The How to Add shortcut provides help about shortcuts and adding them to the Shortcuts toolbar. What's New displays the Release Notes documentation.

To remove the How to Add or What's New shortcuts from the Shortcuts toolbar, move them to a different category. For instructions, see the Move to Category topic in the Shortcuts Organizer help.

If you do not want to keep these shortcuts, remove each one by right-clicking the toolbar shortcut button and selecting Delete from the context menu. Click OK in the confirmation dialog box to remove the shortcut.

See Also