1 / 23

MATLAB Tutorials

MATLAB Tutorials. Session VIII Graphical User Interface using MATLAB. Rajeev Madazhy Email: rmadaz1@lsu.edu Dept of Mechanical Engineering LSU. Last Session…. Introduction to Simulink Solving simple problems using Simulink. Session VII Outline…. Introduction to GUI using MATLAB

raheem
Télécharger la présentation

MATLAB Tutorials

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy Email: rmadaz1@lsu.edu Dept of Mechanical Engineering LSU

  2. Last Session…. • Introduction to Simulink • Solving simple problems using Simulink

  3. Session VII Outline…. • Introduction to GUI using MATLAB • Creating a GUI using MATLAB

  4. GUI….. A graphical user interface (GUI) is a user interface built with graphical objects — the components of the GUI — such as buttons, text fields, sliders, and menus. If the GUI is designed well-designed, it should be intuitively obvious to the user how its components function.

  5. Creating GUI’s with GUIDE….. MATLAB implements GUIs as figure windows containing various uicontrol objects. You must program each object to perform the action you intend it to do when a user activates the component. In addition, you must be able to save and run your GUI. All of these tasks are simplified by GUIDE, the MATLAB graphical user interface development environment.

  6. Using GUIDE…. GUIDE provides several templates, which simple examples that you can modify to create your own GUIs. The templates are fully functional GUIs: their callbacks are already programmed. You can view the code for these callbacks to see how they work, and then modify the callbacks for your own purposes. You can access the templates in two ways: •Start GUIDE by entering guide at the MATLAB prompt. •If GUIDE is already open, select New from the File menu in the Layout Editor.

  7. Blank GUI…. The blank GUI template displayed in the Layout Editor is shown in the following figure.

  8. UI control objects…. • Push Buttons • Toggle Buttons • Check Boxes • Radio Buttons • Edit Text • Static Text • Sliders • Frames • List Boxes • Popup Menus

  9. Push Buttons….. • Push buttons generate an action when pressed (e.g., an OK button may close a dialog box and apply settings) • When you click down on a push button, it appears depressed; when you release the mouse, the button's appearance returns to its non-depressed state; and its callback executes on the button up event

  10. Toggle Buttons…. • Toggle buttons generate an action and indicate a binary state (e.g., on or off) • The callback routine needs to query the toggle button to determine what state it is in • You can do this with a statement that uses the current callback object's handle (gcbo) • get(gcbo,'Value') • MATLAB sets the Value property to 1 when depressed and 0 when not depressed

  11. Check Boxes….. • Generate an action when clicked and indicate their state as checked or not checked • Useful when providing the user with a number of independent choices that set a mode • The Value property indicates the state of the check box by taking on the value 1 or 0 • Value = 1, box is checked. • Value = 0, box is not checked.

  12. Radio Boxes…. • Similar to check boxes, but are intended to be mutually exclusive within a group of related radio buttons (i.e., only one button is in a selected state at any given time) • To make radio buttons mutually exclusive within a group, the callback for each radio button must set the Value property to 0 on all other radio buttons in the group

  13. Edit Text…. • Fields that enable users to enter or modify text strings • Use edit text when you want text as input • The String property contains the text entered by the user.

  14. Static Text…. • Displays lines of text • Typically used to label other controls, provide directions to the user, or indicate values associated with a slider • Users cannot change static text interactively and there is no way to invoke the callback routine associated with it.

  15. Sliders… • Accept numeric input within a specific range by enabling the user to move a sliding bar • The location of the bar indicates a numeric value • Can set Current Value, Range, and Step size

  16. Frames… • Boxes that enclose regions of a figure window • Can make a user interface easier to understand by visually grouping related controls • Have no callback routines associated with them and only uicontrols can appear within frames (axes cannot)

  17. List Boxes…. • Display a list of items (defined using the String property) and enable users to select one or more items • By default, the first item in the list is highlighted when the list box is first displayed • If you do not want any item highlighted, then set the Value property to empty, []

  18. List Box Example…..

  19. Popup Menus…. • Open to display a list of choices (defined using the String property) when users press the arrow • When not open, a popup menu displays the current choice, which is determined by the index contained in the Value property • The first item in the list has an index of 1 • You can query the Value property in the callback routine to determine which choice the user made • Can be used in place of Radio Buttons

  20. Implementation of GUI…. • Use GUIDE to lay out the components interactively • Generate two files that save and launch the GUI

  21. Example : Creating a GUI…. This example will be done in class.

  22. Looking back…. This completes the MATLAB Tutorial. Sessions 1 to 7 covered almost all areas of applications of MATLAB. Specialized areas of MATLAB are using the toolboxes. These are a collection of m-files that are specific to the area of application.

  23. Thank You

More Related