HowtouseGui__sinMatLab

Embed Size (px)

Citation preview

  • 7/27/2019 HowtouseGui__sinMatLab

    1/10

    1

    How to create GUI's in

    MatLAB

    Rigo Dicochea

  • 7/27/2019 HowtouseGui__sinMatLab

    2/10

    2

    Introduction

    Graphical User Interface (GUI)

    MatLab provides Graphical User InterfaceDevelopment Environment(GUIDE)

    A MatLab tool used to create GUIs

    Decide between using GUIDE or writing thecode from scratch

    GUIs give the user a simplified experiencerunning a program

    Associates a function(s) with components ofthe GUI

  • 7/27/2019 HowtouseGui__sinMatLab

    3/10

    3

    Graphical User Interface

    GUI should be consistent and easily understood.

    Provide the user with the ability to use a program

    without having to worry about commands to runthe actual program

    Possible components of a GUI

    Pushbuttons

    Sliders List boxes

    Menus.etc

    Sam le GUI

  • 7/27/2019 HowtouseGui__sinMatLab

    4/10

    4

    3 Essential Characteristics

    Components

    Graphical Components

    pushbuttons, edit boxes, sliders, labels, menus, etc

    Static Components

    Frames, text strings,

    Both are created using the function uicontrol

    Figurescomponents are contained in figures CallbacksThe functions which perform the

    required action when a component is pushed

  • 7/27/2019 HowtouseGui__sinMatLab

    5/10

    5

    GUIDE Properties

    Allows the user to drag and drop componentsthat he/she wants in the layout area of the GUI

    All guide GUIs start with an opening function Callback is performed before user has access to GUI

    Saving automatically generates an .m file and .figfile

    .fig contains the binary GUI layout and .mcontains the code that controls the GUI

  • 7/27/2019 HowtouseGui__sinMatLab

    6/10

    6

    Assessing the Value of Your GUI

    Ask yourself two basic questions when designingyour GUI.

    Do the users always know where they are?

    Do they always know where to go next?

    Constantly answering these two questions willhelp you keep in perspective the goal of yourGUI.

  • 7/27/2019 HowtouseGui__sinMatLab

    7/10

    7

    Callback Editor

    The meat of the GUI process

    Opening function is first callback in every

    guide generated GUI Usually used to generate data used in GUI

    Callbacks define what will happen when a

    figure component is selected Must write CODE!!!!

  • 7/27/2019 HowtouseGui__sinMatLab

    8/10

    8

    GUI EXAMPLE

    Utilize functions

    Surf, Mesh, Contour

    Types of plots performed on data in example

    Peaks

    peaks is a function of two variables, obtained by translating

    and scaling Gaussian distributions

    Membrane

    Sinc

    sinc computes the sinc function of an input vector or array,

    where the sinc function is

  • 7/27/2019 HowtouseGui__sinMatLab

    9/10

    9

    Summary

    At command prompt type guide

    After laying out your GUI in the layour editor

    Define data in Opening Function

    Edit/Align your components using

    Tools Menu

    Align

    View menu

    Property Inspector

    Write the Callbacks

    This is the most difficult aspect when creating GUIs

  • 7/27/2019 HowtouseGui__sinMatLab

    10/10

    10

    Where to Get More Information

    http://www.mathworks.com/products/matlab/

    www.google.com

    http://www.mathworks.com/access/helpdesk/help/techdoc/ref/peaks.html

    http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5439&objectType=file

    http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/creating_guis.html?BB=1

    Daniel Kellerthanks for taking time to help!

    http://www.mathworks.com/products/matlab/http://www.mathworks.com/access/helpdesk/help/techdoc/ref/peaks.htmlhttp://www.mathworks.com/access/helpdesk/help/techdoc/ref/peaks.htmlhttp://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5439&objectType=filehttp://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5439&objectType=filehttp://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5439&objectType=filehttp://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5439&objectType=filehttp://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5439&objectType=filehttp://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5439&objectType=filehttp://www.mathworks.com/access/helpdesk/help/techdoc/ref/peaks.htmlhttp://www.mathworks.com/access/helpdesk/help/techdoc/ref/peaks.htmlhttp://www.mathworks.com/products/matlab/