Introduction

Matlab LogoIn this Matlab GUI tutorial, you will learn how to create and use the Axes component. The Axes component allows you to display graphics, such as graphs and images on your GUI. In this tutorial, we will create two axes on the GUI and plot some simple data onto it. In addition, we will include a reset button to clear the axes and we will also add the standard toolbar to allow the user to zoom, pan, and query the plot.

GUI with two axes and toolbar

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 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 axes icon and add two Axes components to the GUI figure. Next, click on pop-up menu icon and add three Pushbutton components onto the GUI figure.

  4. Double click the Axes component to bring up the Property Inspector. Change the Tag property to axes1, which should already be the default name. Additionally, make sure the other Axes component’s Tag property is named axes2.

    Modify axes tag component properties

  5. Next, let’s modify the properties of the Pushbutton components. Double click on one of the Pushbutton components. Change the String property to Plot Axes 1, and the Tag property to plotAxes1_pushbutton, as shown below.

    Modify pushbutton component properties

    Similarly, double click on the next pushbutton and change the String property to Plot Axes 2 and change the Tag property to plotAxes2_pushbutton.

    Finally, double click on the final pushbutton and change the String property to Clear Axes and change the Tag property to clearAxes_pushbutton.

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

    What your GUI figure should looke like

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

Pages: 1 2