Contact Us:09993897203
Email: dstarenainfo@gmail.com
1st Branch: 121,Malviya Nagar,
New Market,Bhopal-462003
2nd Branch:146/7/2 Premium Center
Zone-1,MP Nagar
Bhopal-462011
Arrow Registration

How to Creating and Displaying a Graphical User Interface in MATLAB?

Creating and Displaying a Graphical User Interface:

MATLAB GUIs are created using a tool called guide, the GUI Development Environment. This tool allows a programmer to layout the GUI, selecting and aligning the GUI components to be placed in it. Once the components are in place, the programmer can edit their properties: name, color, size, font, text to display, and so forth. When guide saves the GUI, it creates a working program including skeleton functions that the programmer can modify to implement the behavior of the GUI. When a guide is executed, it creates the Layout Editor, shown in Figure 1.2. The large white area with grid lines is the layout area, where a programmer can layout the GUI. The Layout Editor window has a palate of GUI components along the left side of the layout area. A user can create any number of GUI components by first clicking on the desired component, and then dragging its outline in the layout area. The top of the window has a toolbar with a series of useful tools that allow the user to distribute and align GUI components, modify

the properties of GUI components, add menus to GUIs, and so on. The basic steps

required to create a MATLAB GUI are:

1. Decide what elements are required for the GUI and what the function of each element will be. Make a rough layout of the components by hand on a piece of paper.

GUI  WINDOW:

 

 

As an example of these steps, let’s consider a simple GUI that contains a single

pushbutton and a single text string. Each time that the pushbutton is clicked, the text string will be updated to show the total number of clicks since the GUI started.

Figure 1.2

 

 

 

 

Graphical User Interface Components

 

 

This section summarizes the basic characteristics of common graphical user interface components. It describes how to create and use each component, as well as the types of events each component can generate. The components discussed in this section are:-

 

 

  • • Text Fields

 

  • • Edit Boxes

 

  • • Frames

 

  • • Pushbuttons

 

  • • Toggle Buttons

 

  • • Checkboxes

 

  • • Radio Buttons

 

  • • Popup Menus

 

  • • List Boxes

 

  • • Slide

 

 

 

 

 

The process of GUI require following steps:-

  • Initializing GUIDE (GUI Creator)
  • Creating the Visual Aspect of the GUI
  • Writing the Code for the GUI Callbacks
  • Launching the GUI

 

Initializing GUI (guide creator):-

First, open up MATLAB. Go to the command window and type in a guide.

 

You should see the following screen appear. Choose the first option

Blank GUI (Default):-

 

 

 

GUI window appears:-

 

 

 

 

 

 

 

 

 

 

 

 

Creating a visual effect in GUI:-

 

Add in all these components to the GUI by clicking on the icon and placing it onto the grid. At this point, your GUI should look similar to the figure below:

 

 

 

 

 

 

 

Writing the code for the GUI call back:-

MATLAB automatically generates a .m file to go along with the figure that you just put together. The .m file is where we attach the appropriate code to the callback of each component. For the purposes of this tutorial, we are primarily concerned only with the callback functions. You don’t have to worry about any of the other function types.

Open up the .m file that was automatically generated when you saved your GUI. In the MATLAB editor, click on the icon, which will bring up a list of the functions within the .m file. Select CALLBACK FOR EACH.

 

Launching the GUI:-

The first way is through the GUIDE editor. Simply press the icon on the GUIDE editor.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

.