You are previewing MATLAB®: An Introduction with Applications, Fourth Edition.
O'Reilly logo
MATLAB®: An Introduction with Applications, Fourth Edition

Book Description

MATLAB: An Introduction with Applications 4th Edition walks readers through the ins and outs of this powerful software for technical computing. The first chapter describes basic features of the program and shows how to use it in simple arithmetic operations with scalars. The next two chapters focus on the topic of arrays (the basis of MATLAB), while the remaining text covers a wide range of other applications.

MATLAB: An Introduction with Applications 4th Edition is presented gradually and in great detail, generously illustrated through computer screen shots and step-by-step tutorials, and applied in problems in mathematics, science, and engineering.

Table of Contents

  1. Copyright
  2. Preface
  3. Introduction
    1. The Purpose of This Book
    2. Topics Covered
    3. The Framework of a Typical Chapter
    4. Symbolic Calculations
    5. Software and Hardware
    6. The Order of Topics in the Book
  4. 1. Starting with MATLAB
    1. 1.1. Starting MATLAB, MATLAB Windows
    2. 1.2. Working in the Command Window
    3. 1.3. Arithmetic Operations with Scalars
      1. 1.3.1. Order of Precedence
      2. 1.3.2. Using MATLAB as a Calculator
    4. 1.4. Display Formats
    5. 1.5. Elementary Math Built-in Functions
    6. 1.6. Defining Scalar Variables
      1. 1.6.1. The Assignment Operator
      2. 1.6.2. Rules About Variable Names
      3. 1.6.3. Predefined Variables and Keywords
    7. 1.7. Useful Commands for Managing Variables
    8. 1.8. Script Files
      1. 1.8.1. Notes About Script Files
      2. 1.8.2. Creating and Saving a Script File
      3. 1.8.3. Running (Executing) a Script File
      4. 1.8.4. Current Folder
    9. 1.9. Examples of MATLAB Applications
    10. 1.10. Problems
  5. 2. Creating Arrays
    1. 2.1. Creating a One-Dimensional Array (Vector)
    2. 2.2. Creating a Two-Dimensional Array (Matrix)
      1. 2.2.1. The zeros, ones and, eye Commands
    3. 2.3. Notes About Variables in MATLAB
    4. 2.4. The Transpose Operator
    5. 2.5. Array Addressing
      1. 2.5.1. Vector
      2. 2.5.2. Matrix
    6. 2.6. Using a Colon : in Addressing Arrays
    7. 2.7. Adding Elements to Existing Variables
    8. 2.8. Deleting Elements
    9. 2.9. Built-in Functions for Handling Arrays
    10. 2.10. Strings and Strings as Variables
    11. 2.11. Problems
  6. 3. Mathematical Operations with Arrays
    1. 3.1. Addition and Subtraction
    2. 3.2. Array Multiplication
    3. 3.3. Array Division
    4. 3.4. Element-by-Element Operations
    5. 3.5. Using Arrays in MATLAB Built-in Math Functions
    6. 3.6. Built-in Functions for Analyzing Arrays
    7. 3.7. Generation of Random Numbers
    8. 3.8. Examples of MATLAB Applications
    9. 3.9. Problems
  7. 4. Using Script Files and Managing Data
    1. 4.1. The MATLAB Workspace and the Workspace Window
    2. 4.2. Input to a Script File
    3. 4.3. Output Commands
      1. 4.3.1. The disp Command
      2. 4.3.2. The fprintf Command
    4. 4.4. The save and load Commands
      1. 4.4.1. The save Command
      2. 4.4.2. The load Command
    5. 4.5. Importing and Exporting Data
      1. 4.5.1. Commands for Importing and Exporting Data
      2. 4.5.2. Using the Import Wizard
    6. 4.6. Examples of MATLAB Applications
    7. 4.7. Problems
  8. 5. Two-Dimensional Plots
    1. 5.1. The plot Command
      1. 5.1.1. Plot of Given Data
      2. 5.1.2. Plot of a Function
    2. 5.2. The fplot Command
    3. 5.3. Plotting Multiple Graphs in the Same Plot
      1. 5.3.1. Using the plot Command
      2. 5.3.2. Using the hold on and hold off Commands
      3. 5.3.3. Using the line Command
    4. 5.4. Formatting a Plot
      1. 5.4.1. Formatting a Plot Using Commands
      2. 5.4.2. Formatting a Plot Using the Plot Editor
    5. 5.5. Plots with Logarithmic Axes
    6. 5.6. Plots with Error Bars
    7. 5.7. Plots with Special Graphics
    8. 5.8. Histograms
    9. 5.9. Polar Plots
    10. 5.10. Putting Multiple Plots on the Same Page
    11. 5.11. Multiple Figure Windows
    12. 5.12. Examples of MATLAB Applications
    13. 5.13. Problems
  9. 6. Programming in MATLAB
    1. 6.1. Relational and Logical Operators
    2. 6.2. Conditional Statements
      1. 6.2.1. The if-end Structure
      2. 6.2.2. The if-else-end Structure
      3. 6.2.3. The if-elseif-else-end Structure
    3. 6.3. The switch-case Statement
    4. 6.4. Loops
      1. 6.4.1. for-end Loops
      2. 6.4.2. while-end Loops
    5. 6.5. Nested Loops and Nested Conditional Statements
    6. 6.6. The break and continue Commands
    7. 6.7. Examples of MATLAB Applications
    8. 6.8. Problems
  10. 7. User-Defined Functions and Function Files
    1. 7.1. Creating a Function File
    2. 7.2. Structure of a Function File
      1. 7.2.1. Function Definition Line
      2. 7.2.2. Input and Output Arguments
      3. 7.2.3. The H1 Line and Help Text Lines
      4. 7.2.4. Function Body
    3. 7.3. Local and Global Variables
    4. 7.4. Saving a Function File
    5. 7.5. Using a User-Defined Function
    6. 7.6. Examples of Simple User-Defined Functions
    7. 7.7. Comparison between Script Files and Function Files
    8. 7.8. Anonymous and Inline Functions
      1. 7.8.1. Anonymous Functions
      2. 7.8.2. Inline Functions
    9. 7.9. Function Functions
      1. 7.9.1. Using Function Handles for Passing a Function into a Function Function
        1. 7.9.1.1. Function handle:
        2. 7.9.1.2. Writing a function function that accepts a function handle as an input argument:
        3. 7.9.1.3. Passing a user-defined function into a function function:
        4. 7.9.1.4. Passing an anonymous function into a function function:
      2. 7.9.2. Using a Function Name for Passing a Function into a Function Function
        1. 7.9.2.1. Writing a function function that accepts a function by typing its name as an input argument:
        2. 7.9.2.2. Passing a user-defined function into another function by using a string expression:
    10. 7.10. Subfunctions
    11. 7.11. Nested Functions
    12. 7.12. Examples of MATLAB Applications
    13. 7.13. Problems
  11. 8. Polynomials, Curve Fitting, and Interpolation
    1. 8.1. Polynomials
      1. 8.1.1. Value of a Polynomial
      2. 8.1.2. Roots of a Polynomial
      3. 8.1.3. Addition, Multiplication, and Division of Polynomials
      4. 8.1.4. Derivatives of Polynomials
    2. 8.2. Curve Fitting
      1. 8.2.1. Curve Fitting with Polynomials; The polyfit Function
      2. 8.2.2. Curve Fitting with Functions Other than Polynomials
    3. 8.3. Interpolation
    4. 8.4. The Basic Fitting Interface
    5. 8.5. Examples of MATLAB Applications
    6. 8.6. Problems
  12. 9. Applications in Numerical Analysis
    1. 9.1. Solving an Equation with One Variable
    2. 9.2. Finding a Minimum or a Maximum of a Function
    3. 9.3. Numerical Integration
    4. 9.4. Ordinary Differential Equations
    5. 9.5. Examples of MATLAB Applications
    6. 9.6. Problems
  13. 10. Three-Dimensional Plots
    1. 10.1. Line Plots
    2. 10.2. Mesh and Surface Plots
    3. 10.3. Plots with Special Graphics
    4. 10.4. The view Command
    5. 10.5. Examples of MATLAB Applications
    6. 10.6. Problems
  14. 11. Symbolic Math
    1. 11.1. Symbolic Objects and Symbolic Expressions
      1. 11.1.1. Creating Symbolic Objects
      2. 11.1.2. Creating Symbolic Expressions
      3. 11.1.3. The findsym Command and the Default Symbolic Variable
    2. 11.2. Changing the Form of an Existing Symbolic Expression
      1. 11.2.1. The collect, expand, and factor Commands
      2. 11.2.2. The simplify and simple Commands
      3. 11.2.3. The pretty Command
    3. 11.3. Solving Algebraic Equations
    4. 11.4. Differentiation
    5. 11.5. Integration
    6. 11.6. Solving an Ordinary Differential Equation
    7. 11.7. Plotting Symbolic Expressions
    8. 11.8. Numerical Calculations with Symbolic Expressions
    9. 11.9. Examples of MATLAB Applications
    10. 11.10. Problems
  15. A. Summary of Characters, Commands, and Functions
  16. B. Answers to Selected Problems