This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Rerun Favorite Commands

Create and Run Favorite Commands

MATLAB® favorite commands (previously called command shortcuts) are an easy way to run a group of MATLAB language statements that you use regularly. For example, you can use a favorite command to set up your environment when you start working, or to set the same properties for figures you create.

To create a favorite command:

  1. On the Home tab, in the Code section, click Favorites and then click New Favorite. The Favorite Command Editor dialog box opens.

  2. In the Label field, enter a name for the favorite command. For this example, enter Setup Workspace.

  3. In the Code field, type the statements you want the favorite command to run. You also can drag and drop statements from the Command Window, the Command History Window, or a file. MATLAB automatically removes any command prompts (>>) from the Code field when you save the favorite command.

    For example, enter these statements:

    format compact
    clear
    workspace
    filebrowser
    clc
    

  4. 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 favorite command appears in the default Favorite Commands category.

  5. In the Icon field, select an icon.

  6. To add the favorite command to the quick access toolbar, select both the Add to quick access toolbar and Show label on quick access toolbar options.

  7. To run the statements in the Code section and ensure they perform the desired actions, click Test.

  8. When you are done configuring the favorite command, click Save.

To run a favorite command, on the Home tab, click Favorites and then click the icon for the desired favorite command. All the statements in the Code field of the Favorite Command Editor execute as if you ran those statements from the Command Window, although they do not appear in the Command History window.

To edit a favorite command, click the icon to the right of the favorite command. To delete a favorite command, click the icon to the right of the favorite command. You also can right-click the favorite command and select Edit Favorite or Delete Favorite.

Organize Favorite Commands

You can organize your favorite commands by storing them in different categories.

To create a new category:

  1. On the Home tab, in the Code section, click Favorites and then click New Category. The Favorite Category Editor dialog box opens.

  2. In the Label field, enter a name for the category. For this example, enter My Favorite Favorites.

  3. In the Icon field, select an icon.

  4. To add the category to the quick access toolbar, select both the Add to quick access toolbar and Show label on quick access toolbar options.

  5. Click Save.

To move a category up or down in the list of categories, or to move a favorite command within a category, drag the category or favorite command to the desired location. You also can use the and buttons to the right of the category.

To change whether a single category or favorite command appears in the quick access bar, click the and icons to the right of the category or favorite command. To add all favorite commands to the quick access bar, on the Home tab, right-click Favorites and select Add to quick access toolbar.

To further configure which favorite commands and categories appear in the quick access bar, on the Home tab, in the Code section, click Favorites and then click Quick Access. Adding and configuring favorite commands and categories in the quick access bar is not supported in MATLAB Online™.

Related Topics