Designing the MATLAB GUI application

MATLAB provides easy ways to design a GUI. Here is one popular method to create a GUI using GUI development environment (GUIDE) (https://in.mathworks.com/discovery/matlab-gui.html). To start GUIDE in MATLAB, just type guide in your MATLAB command line:

Figure 15: MATLAB GUI wizard

You can select a Blank GUI and press OK. You will get a blank GUI, and you can add buttons and text boxes according to your requirements. The following figure shows the basic GUI elements in GUIDE. You can see an empty GUI form and toolbox. We can just drag components from the toolbox to the form. For example, if we need a push button and text edit box, we can just drag and drop those items to the empty form and align them on the form:

Figure 16: MATLAB GUI empty form

After assigning buttons, we have to generate a callback function for them, which will be executed once the button is pressed (or the text edit box is changed). You can create the callback function from the option highlighted in the following figure. When you save it, you will get a *.m file too. This is the MATLAB code file, in which we are going to write the callback functions.

Figure 17: Inserting callback functions

The preceding figure shows how to insert a callback for each button. Right-click on the button and press the Callback option. You'll see the empty callback function for this button:

Figure 18: An empty callback function

In the next section, we will discuss the content of each callback of the application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.28.108