Mod 7 GUI
Mod 7 GUI
______
TITLE:
_____________________________________________________________________________
_
______________________ __ ____________________
DATE PERFORMED DATE SUBMITTED
______________________________ GRADE
INSTRUCTOR NAME AND SIGNATURE
ESIGPLA – Signals, Spectra and Signal Processing
Experiment Title
Objectives:
• Retrieve and modify the properties of the dialog controls using property inspector.
Introduction:
GUI environment with specific callbacks for each menu in the menu bar.
Is a graphical display that contains devices, or components, that enable a user to perform
interactive tasks. To perform these tasks, the user of the GUI does not have to create a
script or type commands at the command line. Often, the user does not have to know the
details of the task at hand.
Components can be menus, toolbars, push buttons, radio buttons, list boxes, sliders, …
GUI Technique
Dialog box MATLAB provides a selection of standard dialog boxes that you
can create with a single function call.
GUI containing just It is often simpler to create GUIs that contain only a few
a few components components programmatically. Each component can be fully
defined with a single function call.
Moderately complex GUIDE simplifies the creation of such GUIs.
Complex GUIs with many Creating such GUIs programmatically lets you control exact
components, and GUIs placement of the components and provides reproducibility
that require Interaction .
with other GUIs
To access GUI Builder
Go to toolbar, click on “File”
Click on “New”
Click on “GUI”
Click on “Blank GUI Default”
Enumerate the types of buttons found in GUI and their description of fucntion
• Push Button - assigns the specified property values, and assigns default values to the
remaining properties. It is also generates an action when pressed.
• Sliders - accept numeric input within a specific range, and enable to move a sliding
bar.
• Radio buttons - are similar to check boxes, but are intended to be mutually exclusive
within a group of related radio buttons.
• Check box - generate an action when selected, useful when providing the user with a
number of independent choices.
• Edit text - text fields enable users to enter or modify text values. It is where we put a
title for the program
• List box – it displays list of items.
• Pop – up Menu – it displays list of choices, useful when you want to provide users
with a number of mutually exclusive choices, but do not want to take up the amount
of space that a series of radio buttons requires.
• Toggle buttons - are controls that execute callbacks when clicked on and indicate
their state, either on or off.
• Axes – it displays the graph.
• Button Group - create container object to exclusively manage radio buttons and
toggle buttons.
In the layout area, select the top push button by clicking it.
In the Property Inspector, select the String property and then replace the existing value with
any word.
Entering Pop-Up Menu Items
The pop-up menu provides a choice of three data sets: peaks, membrane, and sinc. These
data sets correspond to MATLAB functions of the same name. This topic shows you how to
list those data sets as choices in the pop-menu.
1 In the layout area, select the pop-up menu by clicking it.
2 In the Property Inspector, click the button next to String. The String dialog box displays.
3. The GUI is finished. Save the work using the file name “calculatorlastname.m” where
last name is your last name.
4. The design process will take the functionality provided by each GUI component as
shown.
5. Open the matlab editor by typing
>>edit calculatorlastname.m
where calculatorlastname.m is the name of your design
9. Now the calculator is ready to use. Click on the green arrow to run the GUI
MACHINE PROBLEM
Desing a simple GUI with the following specifications:
1. Four (4) push buttons for different frequencies 20 Hz, 50 Hz, 100 Hz and a clear
screen or reset button.
2. One (1) Axes window to the graphs
3. Place a static text to display the following “MODULE 7 GUI MACHINE PROBLEM”
Prepared by “Your name”
4. Requirment. Each time a button indicating the frequency is press, the GUI will
automatically display the frequency in the axes button and the reset to clear the
displayed graph.
5. Label the buttons as such
6. You are to create four programs that you will callback to run the pushbuttons
7. Create a tool bar with help to show how the GUI works and all the 4 buttons. To
create a tool bar, go to the GUI toolbar and click on tools, click on “Menu Editor”. And
the dialog box for menu editor will appear.
Click on untitled and simply rename the headings as help, buttons and sub-buttons to
indicated the buttons that you have on the GUI. Or click on the button toolbar editor
8. You may be creative in designing and using background colors or text colors or text
fonts and sizes.
SYNTAX:
function varargout = simplemachine(varargin)
% SIMPLEMACHINE M-file for simplemachine.fig
% SIMPLEMACHINE, by itself, creates a new SIMPLEMACHINE or raises the
existing
% singleton*.
%
% H = SIMPLEMACHINE returns the handle to a new SIMPLEMACHINE or the
handle to
% the existing singleton*.
%
% SIMPLEMACHINE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SIMPLEMACHINE.M with the given input
arguments.
%
% SIMPLEMACHINE('Property','Value',...) creates a new SIMPLEMACHINE or
raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before simplemachine_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to simplemachine_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = simplemachine_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
help
Machine GUI
Help GUI
Conclusion:
Based on the discussion presented on the previous bullets,
these conclusions have been made:
• GUI is a special environment of MATLAB wherein the
programmer has the option to choose the graphical
elements that he wants to be present on the interface of the
system that he/she wants to design. The GUIDE (Graphical
User Interface Design Environment) stores GUIs in two files,
which are generated the first time you save or run the GUI.
These files are the fig file and the m file. The fig file contains
a complete description of the GUI figure layout and the
components of the GUI. The m file, on the other hand,
contains the code, syntaxes or program that controls the
GUI.
menus that appear when called for and then disappear when
drawing programs.