Create Shortcuts to Rerun Commands

This example shows how to create, run, edit, and organize MATLAB® shortcuts. A MATLAB shortcut is an easy way to run a group of MATLAB language statements that you use regularly. For example, use a shortcut to set up your environment when you start working, or to set the same properties for figures you create.

  1. On the Home tab, click New, and then select Command Shortcut.

    If the Shortcuts tab is currently on the desktop, you can also click New Shortcut in the Manage section.

  2. Complete the Shortcut Editor dialog box:

    1. In the Label field, enter a name for the shortcut.

      For this example, enter my_Shortcut.

    2. In the Callback field, type statements you want the shortcut to run.

      You also can drag and drop statements from the Command Window, Command History Window, or a file.

      For this example, enter these statements:

      format compact

        Tip   If Command Window prompts (>>) appear, MATLAB automatically removes them from the Callback field when you save the shortcut.

    3. In the Category field, type the name of a new category or select an existing category from the drop-down list. If you leave this field blank, the shortcut appears in the General section of the toolbar.

    4. In the Icon field, select an icon.

    5. Click Save.

    The shortcut icon and label appear on the toolbar. If you have more shortcuts on the toolbar than the desktop can display concurrently, use the drop-down list to access them all.

    To organize and edit shortcuts, on the Shortcuts tab, in the Manage section, click Organize Shortcuts to open the Shortcuts Organizer dialog box.

  3. Run a shortcut by clicking its icon on the Shortcuts tab.

    All the statements in the shortcut Callback field execute as if you ran those statements from the Command Window, although they do not appear in the Command History window.

Was this topic helpful?