BUILDING A MATLAB GUI. Education Transfer Plan Seyyed Khandani, Ph.D. IISME 2014

Similar documents
SBT 645 Introduction to Scientific Computing in Sports Science #5

Building a Graphical User Interface

There are two ways to launch Graphical User Interface (GUI). You can either

Still More About Matlab GUI s (v. 1.3) Popup Menus. Popup Menu Exercise. Still More GUI Info - GE /29/2012. Copyright C. S. Tritt, Ph.D.

The Language of Technical Computing. Computation. Visualization. Programming. Creating Graphical User Interfaces Version 1

Graphical User Interface. GUI in MATLAB. Eng. Banan Ahmad Allaqta

Special Topics II: Graphical User Interfaces (GUIs)

GUI Building for Test & Measurement Applications

MATLAB. Creating Graphical User Interfaces Version 7. The Language of Technical Computing

INTRODUCTION TO MATLAB INTERACTIVE GRAPHICS EXERCISES

Mach4 CNC Controller Screen Editing Guide Version 1.0

Creating a Title Block & Border Using Chief Architect. Architectural Design & Residential Construction Penncrest High School

A Simple First-Model Using the Berkeley-Madonna Program

Review: Event Driven Programming & GUI. CSCE155N Matlab Fall 2016

SciGraphica. Tutorial Manual - Tutorials 1and 2 Version 0.8.0

Computational Methods of Scientific Programming. Matlab Lecture 3 Lecturers Thomas A Herring Chris Hill

INTRODUCTION TO THE MATLAB APPLICATION DESIGNER EXERCISES

Numbers Basics Website:

Python Scripting for Computational Science

INTRODUCTION TO VISUAL BASIC 2010

Python Scripting for Computational Science

Interactive Programs

Insight: Measurement Tool. User Guide

Spreadsheet View and Basic Statistics Concepts

Exploring Parametric Equations With the Human Cannonball

Exercise 5: Basic LabVIEW Programming

ELEC451 Integrated Circuit Engineering Using Cadence's Virtuoso Layout Editing Tool

Double Click in in this space to open the the Calculator/Formula

Chapter 4 Determining Cell Size

CHAPTER 1 COPYRIGHTED MATERIAL. Getting to Know AutoCAD. Opening a new drawing. Getting familiar with the AutoCAD and AutoCAD LT Graphics windows

Learn more about Pages, Keynote & Numbers

Excel 2003 Tutorial II

2 Lab 2: LabVIEW and Control System Building Blocks

PowerPoint 2016 Building a Presentation

Simply Personnel Screen Designer

CENTER FOR INNOVATION IN TEACHING AND RESEARCH. ibooks Author. An ibook About Creating ibooks. Create Interactive Books for ipad BY CHAD DENNIS

OrgPublisher Advanced Box Layout Editor

To use the keyboard emulation, you must activate it in the tray icon menu (see 2.6 Enable keyboard emulation)

Chapter 9 Getting Started with Impress:

CNBC Matlab Mini-Course

2.2 - Layouts. Bforartists Reference Manual - Copyright - This page is Public Domain

Investigating Transformations With DESMOS

Text box. Command button. 1. Click the tool for the control you choose to draw in this case, the text box.

Microsoft Excel 2007 Lesson 7: Charts and Comments

This is a demonstration of how you can create a Microsoft Power Point presentation:

ALES Wordpress Editor documentation ALES Research websites

Graphics and GUIs. with MATLAB THIRD EDITION by Chapman & Hall/CRC

Chapter 7 Inserting Spreadsheets, Charts, and Other Objects

Introduction to Microsoft Publisher

Session 3 Introduction to SIMULINK

User Guide. Web Intelligence Rich Client. Business Objects 4.1

Technical Documentation Version 7.3 Output

Introduction To MATLAB Interactive Graphics

Computational Methods of Scientific Programming

A Quick and Easy Guide To Using Canva

Mouse Basics. Dayton Metro Library

Clip Art and Graphics. Inserting Clip Art. Inserting Other Graphics. Creating Your Own Shapes. Formatting the Shape

How to use WordPress to create a website STEP-BY-STEP INSTRUCTIONS

Developing a MATLAB-Based Control System Design and Analysis Tool for Enhanced Learning Environment in Control System Education

Climate-Smart New Orleans

AP ENPS. User's Guide. Version 7.4.5

Section 3 Formatting

DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, X405.5)

Saratoga Springs City School District/Office of Continuing Education Introduction to Microsoft Excel 04 Charts. 1. Chart Types and Dimensions

Beginning PowerPoint: 2010 A Presentation Software

A Simple First-Model Using the Berkeley-Madonna Program

PowerPoint 2007 Cheat Sheet

Poster-making 101 for 1 PowerPoint slide

Q u i c k S ta r t G u i d e

We are IntechOpen, the world s leading publisher of Open Access books Built by scientists, for scientists. International authors and editors

Computer Science 110. NOTES: module 8

Rapid Composer. by bitorbit. v Thank you for purchasing Rapid Composer!

POWERPOINT BASICS: MICROSOFT OFFICE 2010

Anatomy of a Window (Windows 7, Office 2010)

Teach Yourself Microsoft PowerPoint Topic 3: Photo Albums, Slide Sections & Action Buttons

Microsoft Word. Introduction

Lesson 12 Getting Started with Word Essentials

FORMS. The Exciting World of Creating RSVPs and Gathering Information with Forms in ClickDimensions. Presented by: John Reamer

NATIONAL SPORT SCHOOL

Web Accessibility Change Your Mouse Pointer Visibility Handbook

Advanced Layout Tools

ekaizen Lessons Table of Contents 1. ebook Basics 1 2. Create a new ebook Make Changes to the ebook Populate the ebook 41

How to lay out a web page with CSS

CAPE. Community Behavioral Health Data. How to Create CAPE. Community Assessment and Education to Promote Behavioral Health Planning and Evaluation

Power Point 2000 Level 1

How to lay out a web page with CSS

How to set up an Amazon Work Profile for Windows 8

A TUTORIAL ON WORD. Katie Gregory

The purpose of this tutorial is to introduce you to the Construct 2 program. First, you will be told where the software is located on the computer

CS-Studio Display Builder

Introduction to IgorPro

3D Surface Plots with Groups


PowerPoint Multiple OUTPUT types Paper Onscreen Web presentation 6 x 6 rule 6 points 6 words

edev Technologies integreat4tfs 2015 Update 2 Release Notes

How to Resize Airfoils (or Practically Anything, for that matter) using a Macbook and Pages

University of Bahrain College of Applied Studies

How to set up a local root folder and site structure

DbSchema Forms and Reports Tutorial

Microsoft Office PowerPoint 2013 Courses 24 Hours

Transcription:

BUILDING A MATLAB GUI Education Transfer Plan Seyyed Khandani, Ph.D. IISME 2014

Graphical User Interface (GUI) A GUI is useful for presenting your final software. It makes adjusting parameters and visualizing your programs easier. It allows wrapping the software in a form that could be used by people with no knowledge of computer programming. It encourages design-oriented mentality which is essential in engineering education. 2

Guide MATLAB provide a tool, called guide, for creating a GUI. Typing guide in the command window opens the GUIDE Quick Start window shown below: >> guide Begin by using Blank GUI (default) template. 3

Guide Window Guide window and blank GUI panel shown below The window has 3 areas: (1) The menu and menu bar on the top. (2) Buttons to select GUI objects, or controls, on the left. (3) The resizable panel with grid marks where GUI objects will be placed. To resize the panel grab the lower right corner with the mouse and stretch. 4

GUI Objects (controls) in Guide Guide GUI objects are instances of a MATLAB class called uicontrol (user interface control) Push button ------ A button to activate by mouse Radio button ----- Changes state from unselected to selected and back Edit textbox ------ Input data by typing text into the box Pop-up menu ---- A list of options to select one Toggle button ---- Pressed down, it stays down until it is pressed again Axes ----------------- A surface on which to display two and three-dimensional graphs Button group ---- Groups a set of radio buttons or toggle buttons; only one at a time is selected Slide ---------------- Enter a real number by adjusting the position of the slider Checkbox --------- Changes state between select and unselected Push button Radio button Edit textbox Pup-up menu Toggle button Static text --------- Displays a text; use for label or show the result of a calculation Listbox ------------- Display a list of options where several can be selected Table ---------------- Display data in a tabular form Panel --------------- Groups objects together visually ActiveX control For insertion of an ActiveX control made by another program Axes Button group Slide Checkbox Static text Listbox Table Panel ActiveX control 5

MyGUI MyGUI is an example of how to create a GUI. First layout the basic controls for our program. It contains Axes(axes1), Static Text, Edit Text, and Push Button controls. Use drag-and-drop to add GUI objects, or controls, to the panel. Resize and move around each object to look like the image on the right. Selected Object Tag Property Mouse Pointer Position Selected Object Position Resize Box 6

GUI Object Property Inspector Each GUI object has a number of properties. Doubleclick on an object to open the property inspector Sample of properties (1) Tag the name of the control in the code; best to rename it to something identifiable like PlotButton versus button1 (2) String the text that appears on the control (3) ForegroundColor color of the text (4) BackgroundColor color of the control (5) Value current value (initial value is zero) (6) Min and Max depends on the type of control. In slider, for example, they show the range of the value 7

Running MyGUI Change properties of different controls: (1) axes1 tag: PlotArea (2) push button tag: PlotButton string: Plot (3) edit text tag: EquationBox string: Equation (4) static text tag: EquationLabel string: y= Save the setup as MyGUI and then run it by pressing on the menu bar. It will look like the image show above It looks right but it does not do anything until callbacks are defined. 8

GUI File Formats When MyGUI was saved, two files were created. (1) MyGUI.fig contains information about the GUI layout, geometry, and its controls. (2) MyGUI.m contains the program that creates and executes the GUI tool you have made. also contains code that defines a callback for each of the controls in GUI. This m-file loads in the MATLAB editor when MyGUI is first saved. Generally the content of the m-file is left alone except for some callback functions. In the m-file, we will modify a callback function called PlotButton_callback. 9

MyGUI.m File Content MyGUI.m contains a number of functions including: (1) function MyGUI_OpeningFcn(hObject, eventdata, handles, varargin) - This opening function, executes just before MyGUI is made visible. - The function has no output. - Input argument handles is a structure containing handles for all GUI controls such as handles.equationbox, and handles.plotarea. - This function will not be modified (2) function PlotButton_Callback(hObject, eventdata, handles) - This is the callback function for plot button. - The function has no output. - Entering an equation in the Equation box followed by a click on the Plot button, should result in display of the plot of that function in the plot area. Therefore this function must be modified. 10

Writing Callbacks Since the only part to be modified is PlotButton_Callback function. Then add the following code to the end of this function % added code to MyGUI.m x=-10:0.1:10; s=get(handles.equationbox, 'String'); y=eval(s); h=handles.plotarea; plot(h,x,y); xlabel(h,'x-value'); ylabel(h,'y-value'); title(h,'plot of y versus x'); Save MyGUI.m once % an arbitrary range for x % gets the equation entered % eval function finds values of y % records the handle of where % the plot is displayed % plots on the PlotArea 11

Running MyGUI When the m-file code is modified, there is no need to rerun the GUI. The new code will run as a callback allowing a quick testing of the changes made. To run the GUI, the only thing to do is to enter MyGUI in the MATLAB command window: >> MyGUI As a result of running MyGUI.m, the corresponding GUI opens. First enter your function in the Equation box and then click on the Plot button to see the results. 12

Test Results for MyGUI Inputs: y=sin(x), or y=4*x.^3+2*x-1, or y=x.*sin(x) 13

Usefull MATLAB Functions get This function is used to get the properties of a graphic (e.g. gui) object. <var>=get(handle, PropertyName ) where handle is a handle to the object and var represent the value of the property listed set This function sets the value of a property of a graphic (e.g. gui) object. findobj set(handle, PropertyName, property_value) Finds objects with specified property values. handles = findobj('p1name',p1value,...) returns the handles of all objects whose property values match those passed as param-value pairs to the findobj command. 14