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.


Create menu or menu items


m = uimenu
m = uimenu(Name,Value)
m = uimenu(parent)
m = uimenu(parent,Name,Value)


m = uimenu creates a menu in the current traditional figure and returns the Menu object. If there is no traditional figure available, MATLAB® creates one.

m = uimenu(Name,Value) specifies Menu property values using one or more Name,Value pair arguments.

m = uimenu(parent) creates the menu in the specified figure. The figure can be a traditional figure or a UI figure.


m = uimenu(parent,Name,Value) creates the menu in the specified figure and sets one or more Menu property values.


collapse all

Create a traditional figure. Then add a menu called Import and a menu item called CSV File.

f = figure('ToolBar','none');
m = uimenu(f,'Text','Import');
mitem = uimenu(m,'Text','CSV File');

Create a UI figure and add a menu called Show. Then add a menu item called Data Types that has the Checked property set to 'on'.

f = uifigure;
m = uimenu(f,'Text','Show');
mitem = uimenu(m,'Text','Data Types','Checked','on');

Input Arguments

collapse all

Parent figure, specified as a Figure object returned by the figure or uifigure function. If you do not specify a parent figure, the default parent is a traditional figure.

Name-Value Pair Arguments

Example: m = uimenu('Text','Open') creates a menu and sets its label to 'Open'.

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments as Name1,Value1,...,NameN,ValueN.

The properties list here are only a subset.

  • For a list of properties available for GUIDE, or for creating apps with the figure function, see Menu Properties for GUIDE.

  • For a list of properties available for App Designer, or for creating apps with the uifigure function, see Menu Properties for App Designer.

Output Arguments

collapse all

Menu object. Use m to set properties of the menu after creating it.

More About

collapse all

Traditional Figure

A figure that MATLAB creates when you use GUIDE or call the figure function.

UI Figure

A figure that MATLAB creates when you use App Designer or call the uifigure function. For more information on the difference between traditional figures and UI figures, see Graphics Support in App Designer.


To make a menu item respond to user interaction, specify a callback for the MenuSelectedFcn property. The callback responds depending on the location of the menu item and the type of interaction:

  • Left-clicking a menu expands that menu and triggers its callback.

  • While any menu is expanded, hovering any other parent menu (or top-level menu) expands that menu and triggers its callback.

See Also


Introduced before R2006a

Was this topic helpful?