You are previewing Learning to Program with MATLAB: Building GUI Tools.
O'Reilly logo
Learning to Program with MATLAB: Building GUI Tools

Book Description

The text is for instructors who want to use MATLAB to teach introductory programming concepts. Since many students struggle with applying the concepts that underlie good programming practice, Learning to Program with MATLAB: Building GUI Tools was designed upon the observation that student learning is enhanced if the students themselves build the GUI (graphical user interface) tool, construct the computational model, implement the visualization of results, and design the GUI. This text teaches the core concepts of computer programming—arrays, loops, functions, and basic data structures—using MATLAB. The chapter sequence covers text-based programs, then programs that produce graphics, building up to an emphasis on GUI tools. This progression unleashes the real power of MATLAB—creating visual expressions of the underlying mathematics of a problem or design.

Table of Contents

  1. Coverpage
  2. Titlepage
  3. Copyright
  4. Dedication
  5. Contents
  6. Preface
  7. I MATLAB Programming
    1. 1 Getting Started
      1. 1.1 Running the MATLAB IDE
        1. Manipulating windows
      2. 1.2 MATLAB variables
        1. Variable assignment statements
        2. Variable names
        3. Variable workspace
      3. 1.3 Numbers and functions
      4. 1.4 Documentation
      5. 1.5 Writing simple MATLAB scripts
      6. 1.6 A few words about errors and debugging
      7. 1.7 Using the debugger
    2. 2 Strings and Vectors
      1. 2.1 String basics
      2. 2.2 Using the disp command to print a variable’s value
      3. 2.3 Getting information from the user
      4. 2.4 Vectors
      5. 2.5 Operations on vectors
      6. 2.6 Special vector functions
        1. Statistical functions
      7. 2.7 Using rand and randi
    3. 3 Plotting
      1. 3.1 The plot command
      2. 3.2 Tabulating and plotting a simple function
      3. 3.3 Bar graphs and histograms
      4. 3.4 Drawing several plots on one graph
        1. Multiple plots with a single plot command
        2. Combining multiple plots with a hold command
      5. 3.5 Adding lines and text
    4. 4 Matrices
      1. 4.1 Entering and manipulating matrices
      2. 4.2 Operations on matrices
      3. 4.3 Solving linear systems: The backslash operator
        1. Extended example: Solving circuit problems
      4. 4.4 Special matrix functions
    5. 5 Control Flow Commands
      1. 5.1 Conditional execution: The if statement
      2. 5.2 Logical expressions
      3. 5.3 Logical variables
      4. 5.4 for loops
      5. 5.5 while loops
      6. 5.6 Other control flow commands
        1. Switch-case statement
        2. Break statement (not recommended)
    6. 6 Animation
      1. 6.1 Basic animation
      2. 6.2 Animating function plots
      3. 6.3 Kinematics of motion
        1. One-dimensional motion: Constant speed
        2. Motion with constant acceleration
        3. Time-marching dynamics: Nonconstant force
    7. 7 Writing Your Own MATLAB Functions
      1. 7.1 MATLAB function files
        1. Declaring MATLAB functions
      2. 7.2 Function inputs and outputs
      3. 7.3 Local workspaces
      4. 7.4 Multiple outputs
      5. 7.5 Function files
      6. 7.6 Other functional forms
        1. Subfunctions
        2. Nested functions
        3. Anonymous functions
    8. 8 More MATLAB Data Classes and Structures
      1. 8.1 Cell arrays
      2. 8.2 Structures
      3. 8.3 Complex numbers
      4. 8.4 Function handles
      5. 8.5 Other data classes and data structures
  8. II Building GUI Tools
    1. 9 Building a Graphical User Interface
      1. 9.1 Getting started with GUIDE
        1. Saving the GUI to a file
      2. 9.2 Starting an action with a GUI element
      3. 9.3 Communicating with GUI elements
        1. Building SliderTool
        2. Communicating with GUI elements from the command line
      4. 9.4 Synchronizing information with a GUI element
      5. 9.5 Key points from this chapter
    2. 10 Transforming a MATLAB Program into a GUI Tool
      1. 10.1 Creating a GUI tool step by step
      2. 10.2 Further GUI design considerations
    3. 11 GUI Components
  9. III Advanced Topics
    1. 12 More GUI Techniques
      1. 12.1 Waitbars
      2. 12.2 File dialogs
        1. Saving and loading data in .mat files
        2. A GUI interface to file names using uiputfile and uigetfile
      3. 12.3 Reading and writing formatted text files
      4. 12.4 The input dialog
      5. 12.5 The question dialog
      6. 12.6 Sharing application data between functions
      7. 12.7 Responding to keyboard input
      8. 12.8 Making graphic objects interactive
        1. Mouse-click response
        2. Mouse events and object dragging
      9. 12.9 Creating menus in GUIDE
    2. 13 More Graphics
      1. 13.1 Logarithmic plots
      2. 13.2 Plotting functions on two axes
      3. 13.3 Plotting surfaces
      4. 13.4 Plotting vector fields
      5. 13.5 Working with images
        1. Importing and manipulating bit-mapped images
        2. Placing images on surface objects
      6. 13.6 Rotating composite objects in three dimensions
    3. 14 More Mathematics
      1. 14.1 Derivatives
        1. Derivatives of mathematical functions expressed as MATLAB functions
        2. Derivatives of tabulated functions
      2. 14.2 Integration
        1. Integrating tabulated functions
        2. Integrating mathematical functions expressed as MATLAB functions
      3. 14.3 Zeros of a function of one variable
      4. 14.4 Function minimization
        1. Finding a minimum of a function of one variable
        2. Multidimensional minimization
        3. Fitting to an arbitrary function by multidimensional minimization
        4. Solving simultaneous nonlinear equations by multidimensional minimization
      5. 14.5 Solving ordinary differential equations
      6. 14.6 Eigenvalues and eigenvectors
  10. Appendix A: Hierarchy of Handle Graphics Objects
  11. Appendix B: Using LATEX Commands
  12. Index