You are previewing Programming in MATLAB ®.
O'Reilly logo
Programming in MATLAB ®

Book Description

MATLAB ® provides an interactive programming interface for numerical computation and data visualization making it the default framework used for analysis, design and research in many domains of science and industry.

Table of Contents

  1. Cover
  2. Title Page
  3. Contents
  4. Preface
  5. About the Authors
  6. Acknowledgements
  7. 1. Introduction to MATLAB® Desktop
    1. 1.1 Introduction
    2. 1.2 Getting Started
    3. 1.3 MATLAB Desktop
      1. 1.3.1 Command Window
      2. 1.3.2 Command History Window
      3. 1.3.3 Current Directory Browser
      4. 1.3.4 Workspace and Array Editor
      5. 1.3.5 Help Browser
      6. 1.3.6 Edit/Debug Window
      7. 1.3.7 Path Browser
    4. 1.4 Getting Help from Command Window
    5. 1.5 General Syntax
    6. 1.6 Writing Simple Expressions
    7. 1.7 Screen Display Control
    8. 1.8 MATLAB Demonstrations
    9. 1.9 How to Quit MATLAB
    10. Programming Tips and Pitfalls
    11. Summary
    12. Exercises
  8. 2. Matrix Operations and Applications
    1. 2.1 Introduction
    2. 2.2 Data Types in MATLAB
    3. 2.3 MATLAB Array
    4. 2.4 Creating Vectors and Matrices
      1. 2.4.1 Creating Sub-matrices of a Given Matrix
      2. 2.4.2 Changing the Elements of a Matrix
      3. 2.4.3 Creating Special Matrices
      4. 2.4.4 Concatenation
    5. 2.5 Operators
      1. 2.5.1 Matrix Operators
      2. 2.5.2 Matrix Multiplication and Inversion
      3. 2.5.3 Array Operators
      4. 2.5.4 Relational Operators
      5. 2.5.5 Logical Operators
    6. 2.6 Properties of a Matrix
    7. 2.7 Replicating Data to Form a Matrix
    8. Programming Tips and Pitfalls
    9. Summary
    10. Exercises
  9. 3. MATLAB® Graphics and Plotting
    1. 3.1 Introduction
    2. 3.2 2-Dimensional Plots
    3. 3.3 Plot Aesthetics
      1. 3.3.1 Changing the Axes
      2. 3.3.2 Adding Text
    4. 3.4 Multiple Plots
      1. 3.4.1 Multiple Plots on a Window
      2. 3.4.2 Some Important Functions on Multiple Plots
    5. 3.5 Subplotting
    6. 3.6 Some Other Useful 2-D Plots
    7. 3.7 Advanced Concepts on Plot Annotation and Labeling
      1. 3.7.1 Using Handle Graphics
      2. 3.7.2 An Easier Way to Plot Editing
    8. 3.8 3-D Graphics
    9. 3.9 Function Plotters
    10. Programming Tips and Pitfalls
    11. Summary
    12. Exercises
  10. 4. Control Structures, Loops, and File Handling
    1. 4.1 Introduction
    2. 4.2 Conditional Statements
    3. 4.3 Loops
    4. 4.4 Nested Loops
    5. 4.5 Breaking Control Structures (Break and Continue)
    6. 4.6 File Types in Matlab
    7. 4.7 Recording a MATLAB Session
    8. 4.8 Saving and Retrieving Workspace Variables and Spreadsheet Data
    9. 4.9 Handling External Files
      1. 4.9.1 Opening a File
      2. 4.9.2 Writing to a File
      3. 4.9.3 Reading from a File
      4. 4.9.4 Closing a File
    10. 4.10 File Handling (Specific Formats)
    11. 4.11 MATLAB Import Wizard
    12. Programming Tips and Pitfalls
    13. Summary
    14. Exercises
  11. 5. Scripts and Functions
    1. 5.1 Introduction
    2. 5.2 Making Simple Script and Function Files
    3. 5.3 Input and Output Arguments in Functions
      1. 5.3.1 Arguments of Different Types
      2. 5.3.2 Variable Number of Arguments
    4. 5.4 Types of Functions
      1. 5.4.1 Function Functions, Feval, and Inline
      2. 5.4.2 Subfunctions
      3. 5.4.3 Private Functions
      4. 5.4.4 Function Name Resolution
    5. 5.5 Global and Persistent Variables
    6. 5.6 Polynomial Functions
    7. 5.7 Recursive Functions
    8. 5.8 Common Errors in Using Functions
    9. Programming Tips and Pitfalls
    10. Summary
    11. Exercises
  12. 6. Numerical Methods, Calculus, and Statistics
    1. 6.1 Introduction
    2. 6.2 Numerical Integration
      1. 6.2.1 Double and Triple Integrals
    3. 6.3 Numerical Differentiation
    4. 6.4 Interpolation
      1. 6.4.1 Multidimensional Interpolation
    5. 6.5 Curve Fitting
    6. 6.6 Numerical Optimization
    7. 6.7 Linear Equations
      1. 6.7.1 Gauss Elimination
      2. 6.7.2 Ill-conditioned Problems
      3. 6.7.3 Pivoting to Handle Ill-conditioned Problems
    8. 6.8 Solution of Nonlinear Algebraic Equations
      1. 6.8.1 Gauss-Seidel (GS) Method
      2. 6.8.2 GS Solution for a System of Equations
      3. 6.8.3 Newton-Raphson (NR) Method
      4. 6.8.4 NR Solution for a System of Equations
    9. 6.9 Numerical Solution of Ordinary Differential Equations
      1. 6.9.1 Euler’s Method for Solution of Differential Equations
      2. 6.9.2 Euler’s Modified Method
      3. 6.9.3 Runge-Kutta Method (Order-2)
      4. 6.9.4 Runge-Kutta Method (Order-4)
    10. 6.10 Solution of Differential Equations Through ODE Functions
    11. Programming Tips and Pitfalls
    12. Summary
    13. Exercises
  13. 7. Using Memory Efficiently
    1. 7.1 Introduction
    2. 7.2 Matlab Memory Storage
    3. 7.3 Out of Memory Errors
    4. 7.4 Coding Tips for Memory Usage
      1. 7.4.1 Preallocation of Arrays
      2. 7.4.2 Breaking Down the Problem
      3. 7.4.3 Use Temporary Variables Wisely
      4. 7.4.4 Using Less Bytes Per Data Member
      5. 7.4.5 Writing Functions Carefully
      6. 7.4.6 Using Global Variables
    5. 7.5 System-Related Tips for Memory Usage
    6. Programming Tips and Pitfalls
    7. Summary
    8. Exercises
  14. 8. Using the MATLAB® Debugger and Profiler
    1. 8.1 Introduction
    2. 8.2 Types of Errors
    3. 8.3 Using the Debugger
    4. 8.4 Developing Bug-free Programs
    5. 8.5 Common Bugs
      1. 8.5.1 Bug Prevention
      2. 8.5.2 Bug Detection
      3. 8.5.3 Common Run-time Errors
    6. 8.6 Using MATLAB Profiler
      1. 8.6.1 Program Profiling
      2. 8.6.2 Using the Profiler and M-Lint for Enhancing Performance
      3. 8.6.3 When to Use the Profiler
    7. Programming Tips and Pitfalls
    8. Summary
    9. Exercises
  15. 9. Efficient Coding Using Vectorization Technique
    1. 9.1 Introduction
    2. 9.2 Vector Concepts
      1. 9.2.1 MATLAB Indexing
      2. 9.2.2 Utility Functions
    3. 9.3 Loop Conversion
    4. 9.4 Matlab Acceleration
    5. 9.5 Solving Problems WITH Vectorization
    6. Programming Tips and Pitfalls
    7. Summary
    8. Exercises
  16. 10. Precision and Errors
    1. 10.1 Introduction
    2. 10.2 Matlab Infinity and Zero
    3. 10.3 Round-off Errors
    4. 10.4 Propagated Errors
    5. 10.5 Getting Around the Errors
    6. Programming Tips and Pitfalls
    7. Summary
    8. Exercises
  17. 11. Advanced Concepts in Matlab®
    1. 11.1 Introduction
    2. 11.2 Symbolic Processing
      1. 11.2.1 Creating and Using Symbolic Objects
      2. 11.2.2 Expressions Involving Many Symbolic Objects
      3. 11.2.3 Variable Substitution
      4. 11.2.4 Algebraic Operations with Symbolic Expressions
      5. 11.2.5 Differentiation with Symbolic Expressions
      6. 11.2.6 Integration with Symbolic Expressions
      7. 11.2.7 Solving Algebraic Equations
      8. 11.2.8 Solving Differential Equations
      9. 11.2.9 Laplace Transform
    3. 11.3 Cell Arrays and Structures
    4. 11.4 Calling C Functions
      1. 11.4.1 The Distinction between mx and mex Prefixes
      2. 11.4.2 Creating C Language MEX-Files
    5. 11.5 Object Oriented Design
      1. 11.5.1 Classes in MATLAB
      2. 11.5.2 Overloading
      3. 11.5.3 Inheritance
    6. Programming Tips and Pitfalls
    7. Summary
    8. Exercises
  18. 12. Modeling with Simulink®
    1. 12.1 Introduction
    2. 12.2 Creating a Simulink Model
      1. 12.2.1 Starting Simulink
      2. 12.2.2 Opening a New Model File
      3. 12.2.3 Creating Blocks
      4. 12.2.4 Setting the Parameters and Making Connections
      5. 12.2.5 Setting the Simulink Configuration Parameters
      6. 12.2.6 Running/Stopping the Simulation
      7. 12.2.7 Sending Data to the Workspace
    3. 12.3 Dealing with Complex System Equations
    4. 12.4 Creating Subsystems
    5. 12.5 Masking Subsystems
    6. 12.6 Using the Blocksets and Toolboxes
      1. 12.6.1 Physical Modeling with Simulink
      2. 12.6.2 Essential Rules in Physical Modeling
    7. 12.7 Linear State Space Model From Simulink Models
    8. 12.8 Running the Simulink Model Through the Command Line
    9. 12.9 Development of Graphical User Interface
    10. 12.10 Simulink Model File Formats (SLX and MDL)
      1. 12.10.1 Upgrading Models to SLX
      2. 12.10.2 Making Your Model Compatible to Different Simulink Versions
      3. 12.10.3 Saving from One Earlier Simulink Version to Another
    11. Programming Tips and Pitfalls
    12. Summary
    13. Exercises
  19. 13. Digital Image Processing
    1. 13.1 Introduction
      1. 13.1.1 Image as a Matrix
      2. 13.1.2 Getting Information about an Image
      3. 13.1.3 Data Types of Image Variables
      4. 13.1.4 Basic Commands in Image Processing
    2. 13.2 Histogram Processing
      1. 13.2.1 Creating and Displaying Image Histogram
      2. 13.2.2 Histogram Equalization
    3. 13.3 Operations on Images
      1. 13.3.1 Linear Spatial Filtering
      2. 13.3.2 Spatial Noise Filtering
      3. 13.3.3 Morphological Image Processing
    4. 13.4 Point, Line, and Edge Detection
      1. 13.4.1 Point Detection
      2. 13.4.2 Line Detection
      3. 13.4.3 Edge Detection
    5. 13.5 Thresholding
      1. 13.5.1 Global Thresholding
      2. 13.5.2 Local Thresholding
    6. Programming Tips and Pitfalls
    7. Summary
    8. Exercises
  20. Notes
  21. Copyright