Introduction

Matlab LogoIn this Matlab GUI tutorial, you will learn how to create and use the slider component. Sliders are useful controls for choosing a value in a range of values. Common uses are volume controls, seekers for movie and sound files as well as color pickers. An example of a slider is shown below.

Slider GUI

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 isn’t too outdated). Let’s get started!

Create the Visual Aspect of the GUI

  1. Start up Matlab, and type guide in the command line.

    command prompt

  2. Choose to create a new GUI using the “Blank GUI(Default)” option.

    blank GUI

  3. Click on edit text icon and add an Edit Text component to the GUI figure. Next, click on slider icon and add a Slider component onto the GUI figure.

  4. Double click the Edit Text component to bring up the Property Inspector. Change the String property to 0, and change the Tag property to sliderValue_editText as shown in the figure below:

    Modify edit text component properties

  5. Next, let’s modify the properties of the Slider component. First lets sit the Min property to 0, and the Max property to 100. Next, change the Tag property to slider1.

    Modify slider component properties

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

    What your figure should look like

  7. At this point, you also might want to add some Static Text components to specify the min and max values of the slider. 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 limits

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

Pages: 1 2