Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

MATLAB GUI Tutorial for ENGR 1110: Creating and Customizing a Graphical User Interface, Exercises of Matlab skills

A step-by-step tutorial on creating and customizing a Graphical User Interface (GUI) in MATLAB for ENGR 1110 students. It covers creating a new GUI, saving files, updating the layout, adding a button, and editing the code to make the button clear the plot. The tutorial also includes adding a standard MATLAB plot window toolbar and demonstrates the working GUI to the TA.

Typology: Exercises

2021/2022

Uploaded on 09/27/2022

kyran
kyran 🇬🇧

4.3

(7)

220 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MATLAB Graphical User Interface (GUI) Tutorial for ENGR 1110
1. At the MATLAB prompt, type guide.
You should see this figure window:
2. Select the Create New GUI tab, and select the template “GUI with Axes and Menu”. Click
OK, and then you should get this:
3. Press the green arrow on the right of the toolbar. You will get this message:
pf3
pf4
pf5
pf8

Partial preview of the text

Download MATLAB GUI Tutorial for ENGR 1110: Creating and Customizing a Graphical User Interface and more Exercises Matlab skills in PDF only on Docsity!

MATLAB Graphical User Interface (GUI) Tutorial for ENGR 1110

  1. At the MATLAB prompt, type guide.

You should see this figure window:

  1. Select the Create New GUI tab, and select the template “GUI with Axes and Menu”. Click OK, and then you should get this:
  2. Press the green arrow on the right of the toolbar. You will get this message:
  1. Select Yes.
  2. You will get a Save As dialog box. Choose a folder and a name to save your GUI files. In this example, my folder is gui and my name is myfirstgui.

The MATLAB Editor should appear with myfirstgui.m loaded. You might also get a dialog box that looks like this:

Now drag the black square handle at the lower right of the layout grid and make the grid larger. Click in the white area where the axes1 text is displayed. Handles (little black squares) should appear on the axes. Drag the handles to make the axes smaller. This makes room for a new button we are going to add.

  1. Now drag a pushbutton icon (labeled OK) from the palette on the left onto the layout grid.
  1. Right-click on the Push Button icon and select Property Inspector. You will get a new window:
  2. In the Inspector, scroll down to the property named String. Edit the value from “Push Button” to “Clear Plot”

When edited, it should look like this in the editor window (may show pushbutton4 instead of pushbutton1):

  1. Now run the GUI by pressing the green arrow (Run) at the top of the editor window.
  2. In the GUI, press the Clear Plot button, and then the Update button. They should now both work.
  3. Finally, add this one line of code near the beginning of the m-file:

set(hObject,'toolbar','figure');

This should be placed just before the line that reads:

guidata(hObject, handles);

The edited section of code should look like as shown below. The line we just added is at line 58 in my editor (your line number may vary slightly):

  1. Now run the GUI. You should have a plot toolbar. Display the surface plot by selecting surf(peaks) from the drop-down list. Use the plot toolbar to zoom, and to rotate it in 3D.
  2. Demonstrate your working GUI to your TA and have your worksheet initialed.

END OF GUI TUTORIAL