| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
| On this page… |
|---|
Creating MATLAB Shortcuts — Tutorials |
A MATLAB shortcut is an easy way to run a group of MATLAB language statements that you use regularly. Although like an M-file script, a shortcut is not an M-file. It need not be on the search path nor in the current folder when you run it, and MATLAB does not store it as an M-file.
You can create shortcuts that you run from the Start button or the shortcut toolbar, depending on your preferences.
MATLAB maintains shortcut information in the shortcuts.xml file. This file is located in the folder displayed when you type prefdir in the Command Window. It is unlikely that you will need to access this file, because MATLAB updates it automatically.
Create MATLAB shortcuts to:
Run a group of functions you use frequently.
For example, use a shortcut to set up your environment when you start working. This practice is useful when you do not use a startup file, or if there are statements you do not want to include in the startup file.
Set the same properties for figures you create, such as adding a legend and setting the background color.
Run a long statement, such as changing the current folder (cd) when the path names are long.
Run a single function that you use frequently, such as clc to clear the Command Window.
Run a statement that you use frequently, but have trouble remembering.
You can create a MATLAB shortcut to run from the desktop Start button, or from the shortcuts toolbar, as described in the tutorials that follow. Both tutorials create a shortcut for a project called the Sea Temperature project. For these tutorials, you set up your environment in a certain way by running a series of MATLAB language statements. You create a shortcut called sea_temp_env, which contains these statements. Then, you run the shortcut to execute all the statements with a single click. The statements are:
more on format long e cd I:/mymfiles/sea_temp_project clear workspace filebrowser clc
To create a start button shortcut, follow these steps:
Complete the Shortcut Editor dialog box.
Provide a shortcut name in the Label field, for example, sea_temp_environment.
Put the statements in the Callback field as shown in the following illustration. You can:
Enter them by typing.
Copy and paste them from a desktop tool—if prompts (>>) from the Command Window appear, MATLAB automatically removes them when you save the shortcut.
Drag them from a desktop tool.
Edit them, if necessary.
The Callback field uses the Editor preferences for keyboard shortcuts, colors, and fonts.
Assign a Category, which is like a folder for organizing shortcuts. For this example, specify sea_temp_project.
Use the default shortcuts icon
, or select your own.
Click Save.

MATLAB adds the shortcut to the Shortcuts entry in the Start button.
For more information on the options in the Shortcut Editor dialog box, click the Help button.
This example assumes that you have the following statements in the Command Window:
more on format long e cd I:/mymfiles/sea_temp_project clear workspace filebrowser clc
Follow these steps:
If the shortcuts toolbar is not currently on the desktop, choose Desktop > Toolbars > Shortcuts.
Select statements from the Command Window.
You can also select statements from the Command History Window or an M-file.
Drag the selection to the desktop Shortcuts toolbar.
This illustration shows highlighted statements being dragged from the Command Window to the toolbar.

Create the shortcut by completing the Shortcut Editor dialog box:
In the Label field, enter a name for the shortcut.
In the Callback field, edit the selected statements, if necessary.
If prompts (>>) from the Command Window appear, MATLAB automatically removes them when you save the shortcut.
Do not change the Category field value, Toolbar Shortcuts.
For the shortcut to appear on the toolbar, this value must remain as-is.
In the Icon field, select an icon, or keep the default.
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 run a shortcut, do one of the following:
To run a Start menu shortcut, select Start > Shortcuts. Then select the shortcut name, or a category submenu, followed by the shortcut name.
To run a toolbar shortcut, click its icon on the shortcuts toolbar.

All the statements in the shortcut Callback field execute. It is as if you ran those statements from the Command Window, although they do not appear in the Command History window.
To create categories for shortcuts, and to move, edit, and delete shortcuts, perform these steps:
Open the Shortcuts Organizer dialog box, by doing one of the following:
Click the Start button and select Shortcuts > Organize Shortcuts.
From the shortcuts toolbar context menu, choose Organize Shortcuts.
The Shortcuts Organizer dialog box appears. When you select a shortcut category in the dialog box, the Edit Shortcut button replaces the Rename Category button.

To edit and organize shortcuts and categories, do one of the following:
Click buttons in the dialog box.
Right-click an item and select an action from the context menu.
Changes take effect immediately.
For more information about using the Shortcuts Organizer dialog box, click the Help button.
For step-by-step instructions on how to add a shortcut to the toolbar, see Creating MATLAB Toolbar Shortcuts.
By default, the Shortcuts toolbar includes these two shortcuts:
How to Add—Provides help about shortcuts and adding them to the Shortcuts toolbar.
What's New —Displays the Release Notes documentation.
If you want to remove one or both of these shortcuts, see Deleting MATLAB Shortcuts from the Toolbar.
To hide the shortcut labels on the toolbar, and leave just the shortcut icon:
Right-click in the Shortcuts toolbar.
From the context menu, select Show Labels, to clear the check mark next to the item.
Now, when you move the mouse over a shortcut icon, its label appears as a tooltip.
To redisplay a shortcut label that you previously hid:
Right-click on the Shortcuts toolbar.
From the context menu, check the Show Labels item by selecting it. The label reappears on the toolbar.
To remove a shortcut:
Right-click the toolbar shortcut button.
From the context menu. select Delete.
Click OK in the confirmation dialog box.
In addition to the previously described ways to create shortcuts, you can do any of the following:
From the Command History window, select MATLAB language statements, right-click, and select Create Shortcut from the context menu. By default, MATLAB assigns shortcuts created from the Command History window to the Toolbar Shortcuts category. Shortcuts in the Toolbar Shortcuts category appear on the Shortcuts toolbar.
Drag statements from a desktop tool, such as the Command History, onto the Start button.
Right-click the Shortcuts toolbar, and select New Shortcut. Complete the resulting Shortcut Editor dialog box. If you maintain the Toolbar Shortcuts category, the shortcut appears on the shortcuts toolbar.
![]() | Examples of Desktop Arrangements | Performing Desktop Actions Using the Keyboard | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |