Introduction

Matlab LogoIn this Matlab GUI tutorial, you will learn how to create and use the Pop-up Menu component. Pop-up menus are used as a control for choosing between a set of options. When the user clicks on the Pop-up menu, the menu expands, revealing a set of choices that the user can pick. A common use for Pop-up menus is a font size selector (shown below).

Pop-up Menu Expanded

This tutorial is written for those with little or no experience creating a Matlab GUI (Graphical User Interface). If you’re new to creating GUIs in Matlab, you should visit this tutorial first. Basic knowledge of Matlab is not required, but recommended. Matlab version 2007a is used in writing this tutorial. Both earlier versions and new versions should be compatible as well (as long as it isan’t too outdated). Let’s get started!

Create the Visual Aspect of the GUI

  1. First, open up Matlab. Go to the command window and type in guide.

    Command Window

  2. You should see the following screen appear. Choose the first option Blank GUI (Default).

    GUI options

  3. Click on static text icon and add a Static Text component to the GUI figure. Next, click on pop-up menu icon and add a Pop-up Menu component onto the GUI figure.

  4. Double click the Static Text component to bring up the Property Inspector. Change the String property to Testing!!!, and change the Tag property to testing_staticText as shown in the figure below:
    Modify static text component properties
    You can also modify the BackgroundColor property if you desire.

  5. Next, let’s modify the properties of the Pop-up Menu component. First, click on the icon on the String property line as shown below. This allows you to edit the description for each option in the Pop-Up Menu.
    Modify slider component properties

    After clicking on the icon, you should now see the following window. Fill in the window as shown below:
    Modify String Property of Pop-up Menu

    In addition, I set the Tag property to popupmenu1, which is the default name. You might want to make sure that its named properly before you move on.

  6. Here’s what your figure should look like after you add the components and modify them. What your GUI should look like

  7. At this point, you also might want to add some Static Text components to add some description tags to the GUI. You can modify their text by double clicking on the component and changing the String property. It’s not required, but I highly recommend it.

    Add on descriptions

  8. Save your GUI wherever you please with your desired filename.

Pages: 1 2