MATLAB GUI

HOME PAGE | THE AUTHOR | THE BOOK | EXCERPT PAGE | CODE SAMPLES | REVIEWS PAGE | CONTACT


 
MATLAD Advanced GUI Table of Contents
  Excerpted from the Introduction...
 

MATLAB Introduction

In 1977, Cleve Moler developed the first version of MATLAB® software using the FORTRAN computer language and it was designed for solving systems of linear equations and performing matrix calculations. At that time, MATLAB was a relatively simple application with a command line interface and an arsenal of about 80 functions. In the early 1980's, Jack Little, a former graduate from Stanford University, was introduced to Cleve's MATLAB software through colleagues at Stanford. Jack soon took interest in MATLAB and Jack and Cleve formed The MathWorks in 1984 to develop MATLAB into a commercial software application.

Throughout the 1980's and 1990's, MATLAB evolved from a FORTRAN based matrix-solving application into a universal computing toolset complete with thousands of built-in computational and graphical functions. In the mid 1990's, around the time when I was taking my first image processing course in engineering, The MathWorks incorporated graphical user interface, GUI, capabilities into MATLAB. Recent versions of MATLAB, such as versions 6 and 7 or later, have advanced GUI development and graphics capabilities including real-time graphics support, 2D and 3D hardware acceleration using OpenGL, and many of the standard user interface controls common to graphical operating systems.

This book is intended to introduce you to the capabilities of MATLAB for developing GUI applications, explain the details of MATLAB GUI development, and finally cover advanced GUI topics such as designing multiple figure GUIs and real-time graphics and animation. The intended audience for this book ranges from novice MATLAB users who are looking for a complete guide for GUI development to veteran users who wish to learn more about advanced topics such as multiple figure GUIs and real-time event handling.

Available at Amazon.com and fine bookstores everywhere

Chapter 1: MATLAB GUI Introduction

1.1 Why Develop GUIs Using MATLAB?
1.1.1 High-Level Script Based Development
1.1.2 Seamless Integration with Existing MATLAB Computational Power
1.1.3 Operating System Independent GUI Applications
1.1.4 User Interactivity and Real-time Measurements
1.2 MATLAB Capabilities For GUI Development
1.2.1 Handle Graphics Objects
1.2.2 Figures, Axes, and UIControls
1.2.3 GUIDE, Graphical User Interface Development Environment
1.2.4 Event Handling: Callback Functions, Timers, and Mouse/Keyboard Input
1.2.5 Global Variables
1.2.6 Stand-alone Executable GUIs
1.3 Where To Download M-files

Chapter 2: MATLAB Handle Graphics Programming

2.1 Introduction To Handle Graphics Objects
2.1.1 HG Object Hierarchy
2.1.2 The Root Object
2.2 Handle Graphics Objects and Properties
2.2.1 Retrieving and Storing Properties Using set( ) and get( )
2.2.2 Common HG Object Properties
2.3 Figure Object Properties
2.3.1 Figure Properties
2.3.2 Settings
2.3.3 Callback Functions
2.4 Axes Properties
2.4.1 Axes Object Settings
2.4.1.1 Axes Properties For 2D Plot Applications
2.4.1.2 Axes Properties For 3D Plot Applications
2.4.1.3 Axes Properties For Imaging Applications 43
2.4.2 Axes Object Callback Functions 50
2.5 Axes Child Object Properties 50
2.5.1 Core Objects 50
2.5.1.1 Image Objects 50
2.5.1.2 Light Objects 52
2.5.1.3 Line Objects 52
2.5.1.4 Patch Objects 54
2.5.1.5 Rectangle Objects 57
2.5.1.6 Surface Objects 59
2.5.1.7 Text Objects 61
2.5.2 Plot Objects 67
2.5.3 Group Objects 69
2.5.4 Annotation Objects 73
2.6 UI Object Properties 76
2.6.1 UIControls 77
2.6.1.1 Check Boxes 83
2.6.1.2 Radio Buttons 85
2.6.1.3 Edit Text Boxes 90
2.6.1.4 Static Text Labels 93
2.6.1.5 List Boxes 94
2.6.1.6 Push Buttons 99
2.6.1.7 Toggle Buttons 105
2.6.1.8 Sliders 108
2.6.1.9 Popup Menus 112
2.6.2 UIMenu 115
2.6.3 UIContextMenu 120
2.6.4 UIButtonGroup 125
2.6.5 UIPanel 129
2.6.6 UIToolbar, UIPushTool, and UIToggleTool 132

Chapter 3: MATLAB GUIDE: GUI Development Environment 137

3.1 Introduction To GUIDE, Graphical User Interface Development Environment 137
3.1.1 Advantages of Using GUIDE 138
3.1.2 Getting Started With GUIDE 139
3.2 GUIDE Options and Setup 142
3.2.1 GUI Options 143
3.2.2 Grids and Rulers 146
3.2.3 GUI Figure Size 146
3.3 Property Inspector and Object Browser 147
3.3.1 Property Inspector 147
3.3.2 Object Browser 148
3.4 Generating Callback Functions 150
3.4.1 Callback Naming Conventions 150
3.5 Creating User Interface Menus 152
3.5.1 Menu Bars 153
3.5.2 Context Menus 154
3.6 Automatic M-file Code Generation and Structure 157
3.6.1 Auto-generated M-file Structure 157
3.6.2 Main Function 157
3.6.3 Main Function Initialization 159
3.6.4 Renaming GUI Projects 160
3.6.5 Removing GUI Objects and Associated Callback Functions 160

Chapter 4: Structure of MATLAB GUIs

4.1 GUI Design Style, Layout, and Program Flow 161
4.1.1 Defining The GUI 161
4.1.2 GUI Design Styles and Layout 162
4.1.3 Program Flow 162
4.1.4 Example of Defining A GUI: FigView 163
4.2 Handles Data Structure Organization 165
4.2.1 Handles Data Structures 165
4.2.2 Initializing GUI Properties and Variables 168
4.2.3 Handles and Callback Function Examples 170
4.2.4 Limitations of Handles 177
4.3 Event Handling 178
4.3.1 The Event Queue 178
4.3.2 Mouse Events 182
4.3.3 Key Press Events 190
4.3.4 Timer Events 196
4.4 Dialog Boxes 202
4.4.1 MATLAB Built-in Dialog Boxes 202
4.4.2 Custom Dialog Boxes 215

Chapter 5: Advanced MATLAB GUI Designs

5.1 Multiple Figure GUIs 225
5.1.1 Global Variables 225
5.1.2 Interactive Multiple Control GUIs 229
5.1.3 EquationAnimator: Multiple Figure GUI Design Example 233
5.2 Real-time GUIs and Animation 241
5.2.1 Using Timers For Loops 241
5.2.2 Animating HG Objects 242
5.2.3 Real-time Controls 245
5.3 Custom GUI Control Styles 279
5.3.1 Image Mapped Controls, IMCs 279
5.3.2 Image Mapped GUI Layouts 281
5.3.3 IMC Callbacks 281
5.3.4 Highlighting IMCs Based On Mouse Pointer 282
5.4 Creating Stand-Alone Executable GUIs 292
5.4.1 Requirements and Limitations 292
5.4.2 M-file Only Executable Generation 293
5.4.3 Command Window 294
5.4.4 Deploying Your GUI Application 294

Bibliography 297

Index 298


Exercises

Exercise 2.1: HG Object Manipulation Using set() and get() 15
Exercise 2.2: Using The Parent Property To Control Graphic Objects 19
Exercise 2.3: Creating Custom Figures Using Properties 28
Exercise 2.4: Axes Properties For 2D Graphics Applications 35
Exercise 2.5: Axes Properties For 3D Plot Applications 38
Exercise 2.6: Axes Properties For Imaging: Photos and Video 44
Exercise 2.7: Using Text Objects As Interactive Controls 62
Exercise 2.8: UIMenu Programming 116
Exercise 2.9: Using UIToolbars 133
Exercise 3.1: Creating A GUI Project 147
Exercise 3.2: Property Inspector and Object Browser Tools 148
Exercise 3.3: Callback Function Naming Using The Tag Property 151
Exercise 3.4: Creating Menu Bars and Context Menus 155
Exercise 4.1: FigView Layout and Handles Structure Creation 169
Exercise 4.2: Mouse Event Programming, FigView 185
Exercise 4.3: Dialog Boxes 211
Exercise 5.1: GHS Architecture For EquationAnimator 239
Exercise 5.2: Implementing EquationAnimator 247



Examples

Example 2.1: Patch Objects 55
Example 2.2: Rectangle Objects 57
Example 2.3: Plot Objects 68
Example 2.4: Check Box Programming 83
Example 2.5: Switch Yard Method For Radio Buttons 86
Example 2.6: Separate Callbacks Method For Radio Buttons 89
Example 2.7: Edit Text Box Single and Multiple Line Inputs 91
Example 2.8: Static Text Labels 93
Example 2.9: Multiple Input List Box 95
Example 2.10: List Box Control Using Cell Arrays 98
Example 2.11: Push Button Controls 100
Example 2.12: Pushbuttons With Graphical Icons Using CData 103
Example 2.13: Toggle Buttons 105
Example 2.14: Slider Controls 110
Example 2.15: Popup Menus 112
Example 2.16: Context Menus 122
Example 2.17: UIButtonGroup Objects 126
Example 2.18: UIPanel Object Group Manipulation 130
Example 4.1: Example of Defining A GUI: Figview 163
Example 4.2: Event Processing 181
Example 4.3: Key Press Event Processing 195
Example 4.4: Timer Events 199
Example 4.5: Custom Dialog GUI 217
Example 5.1: EquationAnimator: Multiple Figure GUI Design 233
Example 5.2: Animation of Plot Data 243
Example 5.3: Real-time Slider Control 247
Example 5.4: Image Mapped Controls, IMCs 281
Example 5.5: Image Mapped Controls: AVI Video Player 283
Example 5.6: Compiling Stand-alone Executables 295