| |
| |
Preface | |
| |
| |
Introduction | |
| |
| |
| |
Starting with MATLAB | |
| |
| |
| |
Starting MATLAB, MATLAB Windows | |
| |
| |
| |
Working in the Command Window | |
| |
| |
| |
Arithmetic Operations with Scalars | |
| |
| |
| |
Order of Precedence | |
| |
| |
| |
Using MATLAB as a Calculator | |
| |
| |
| |
Display Formats | |
| |
| |
| |
Elementary Math Built-In Functions | |
| |
| |
| |
Defining Scalar Variables | |
| |
| |
| |
The Assignment Operator | |
| |
| |
| |
Rules About Variable Names | |
| |
| |
| |
Predefined Variables and keywords | |
| |
| |
| |
Useful Commands for Managing Variables | |
| |
| |
| |
Script Files | |
| |
| |
| |
Notes About Script Files | |
| |
| |
| |
Creating and Saving a Script File | |
| |
| |
| |
Running (Executing) a Script File | |
| |
| |
| |
Current Directory | |
| |
| |
| |
Examples of MATLAB Applications | |
| |
| |
| |
Problems | |
| |
| |
| |
Creating Arrays | |
| |
| |
| |
Creating a One-Dimensional Array (Vector) | |
| |
| |
| |
Creating a Two-Dimensional Array (Matrix) | |
| |
| |
| |
The zeros, ones and eye Commands | |
| |
| |
| |
Notes About Variables in MATLAB | |
| |
| |
| |
The Transpose Operator | |
| |
| |
| |
Array Addressing | |
| |
| |
| |
Vector | |
| |
| |
| |
Matrix | |
| |
| |
| |
Using a Colon: in Addressing Arrays | |
| |
| |
| |
Adding Elements to Existing Variables | |
| |
| |
| |
Deleting Elements | |
| |
| |
| |
Built-In Functions for Handling Arrays | |
| |
| |
| |
Strings and Strings as Variables | |
| |
| |
| |
Problems | |
| |
| |
| |
Mathematical Operations with Arrays | |
| |
| |
| |
Addition and Subtraction | |
| |
| |
| |
Array Multiplication | |
| |
| |
| |
Array Division | |
| |
| |
| |
Element-by-Element Operations | |
| |
| |
| |
Using Arrays in MATLAB Built-In Math Functions | |
| |
| |
| |
Built-In Functions for Analyzing Arrays | |
| |
| |
| |
Generation of Random Numbers | |
| |
| |
| |
Examples of MATLAB Applications | |
| |
| |
| |
Problems | |
| |
| |
| |
Using Script Files and Managing Data | |
| |
| |
| |
The MATLAB Workspace and the Workspace Window | |
| |
| |
| |
Input to a Script File | |
| |
| |
| |
Output Commands | |
| |
| |
| |
The disp Command | |
| |
| |
| |
The fprintf Command | |
| |
| |
| |
The save and load Commands | |
| |
| |
| |
The save Command | |
| |
| |
| |
The load Command | |
| |
| |
| |
Importing and Exporting Data | |
| |
| |
| |
Commands for Importing and Exporting Data | |
| |
| |
| |
Using the Import Wizard | |
| |
| |
| |
Examples of MATLAB Applications | |
| |
| |
| |
Problems | |
| |
| |
| |
Two-Dimensional Plots | |
| |
| |
| |
The plot Command | |
| |
| |
| |
Plot of Given Data | |
| |
| |
| |
Plot of a Function | |
| |
| |
| |
The fplot Command | |
| |
| |
| |
Plotting Multiple Graphs in the Same Plot | |
| |
| |
| |
Using the plot Command | |
| |
| |
| |
Using the hold on, hold off Commands | |
| |
| |
| |
Using the line Command | |
| |
| |
| |
Formatting a Plot | |
| |
| |
| |
Formatting a Plot Using Commands | |
| |
| |
| |
Formatting a Plot Using the Plot Editor | |
| |
| |
| |
Plots with Logarithmic Axes | |
| |
| |
| |
Plots with Error Bars | |
| |
| |
| |
Plots with Special Graphics | |
| |
| |
| |
Histograms | |
| |
| |
| |
Polar Plots | |
| |
| |
| |
Plotting Multiple Plots on the Same Page | |
| |
| |
| |
Multiple Figure Windows | |
| |
| |
| |
Examples of MATLAB Applications | |
| |
| |
| |
Problems | |
| |
| |
| |
User-Defined Functions and Function Files | |
| |
| |
| |
Creating a Function File | |
| |
| |
| |
Structure of a Function File | |
| |
| |
| |
Function Definition Line | |
| |
| |
| |
Input and Output Arguments | |
| |
| |
| |
The H1 Line and Help Text Lines | |
| |
| |
| |
Function Body | |
| |
| |
| |
Local and Global Variables | |
| |
| |
| |
Saving a Function File | |
| |
| |
| |
Using a User-Defined Function | |
| |
| |
| |
Examples of Simple User-Defined Functions | |
| |
| |
| |
Comparison Between Script Files and Function Files | |
| |
| |
| |
Anonymous and Inline Functions | |
| |
| |
| |
Anonymous Functions | |
| |
| |
| |
Inline Functions | |
| |
| |
| |
Function Functions | |
| |
| |
| |
Using Function Handles for Passing a Function into a Function Function | |
| |
| |
| |
Using a Function Name for Passing a Function into a Function Function | |
| |
| |
| |
Subfunctions | |
| |
| |
| |
Nested Functions | |
| |
| |
| |
Examples of MATLAB Applications | |
| |
| |
| |
Problems | |
| |
| |
| |
Programming in MATLAB | |
| |
| |
| |
Relational and Logical Operators | |
| |
| |
| |
Conditional Statements | |
| |
| |
| |
The if-end Structure | |
| |
| |
| |
The if-else-end Structure | |
| |
| |
| |
The if-elseif-else-end Structure | |
| |
| |
| |
The switch-case Statement | |
| |
| |
| |
Loops | |
| |
| |
| |
for-end Loops | |
| |
| |
| |
while-end Loops | |
| |
| |
| |
Nested Loops and Nested Conditional Statements | |
| |
| |
| |
The break and continue Commands | |
| |
| |
| |
Examples of MATLAB Applications | |
| |
| |
| |
Problems | |
| |
| |
| |
Polynomials, Curve Fitting, and Interpolation | |
| |
| |
| |
Polynomials | |
| |
| |
| |
Value of a Polynomial | |
| |
| |
| |
Roots of a Polynomial | |
| |
| |
| |
Addition, Multiplication, and Division of Polynomials | |
| |
| |
| |
Derivatives of Polynomials | |
| |
| |
| |
Curve Fitting | |
| |
| |
| |
Curve Fitting with Polynomials, the polyfit Function | |
| |
| |
| |
Curve Fitting with Functions Other than Polynomials | |
| |
| |
| |
Interpolation | |
| |
| |
| |
The Basic Fitting Interface | |
| |
| |
| |
Examples of Matlab Applications | |
| |
| |
| |
Problems | |
| |
| |
| |
Three-Dimensional Plots | |
| |
| |
| |
Line Plots | |
| |
| |
| |
Mesh and Surface Plots | |
| |
| |
| |
Plots with Special Graphics | |
| |
| |
| |
The view Command | |
| |
| |
| |
Examples of MATLAB Applications | |
| |
| |
| |
Problems | |
| |
| |
| |
Applications in Numerical Analysis | |
| |
| |
| |
Solving an Equation with One Variable | |
| |
| |
| |
Finding a Minimum or a Maximum of a Function | |
| |
| |
| |
Numerical Integration | |
| |
| |
| |
Ordinary Differential Equations | |
| |
| |
| |
Examples of MATLAB Applications | |
| |
| |
| |
Problems | |
| |
| |
| |
Symbolic Math | |
| |
| |
| |
Symbolic Objects, and Symbolic Expressions | |
| |
| |
| |
Creating Symbolic Objects | |
| |
| |
| |
Creating Symbolic Expressions | |
| |
| |
| |
The findsym Command and the Default Symbolic Variable | |
| |
| |
| |
Changing the Form of an Existing Symbolic Expression | |
| |
| |
| |
The collect, expand, and factor Commands | |
| |
| |
| |
The simplify and simple Commands | |
| |
| |
| |
The pretty Command | |
| |
| |
| |
Solving Algebraic Equations | |
| |
| |
| |
Differentiation | |
| |
| |
| |
Integration | |
| |
| |
| |
Solving an Ordinary Differential Equation | |
| |
| |
| |
Plotting Symbolic Expressions | |
| |
| |
| |
Numerical Calculations with Symbolic Expressions | |
| |
| |
| |
Examples of MATLAB Applications | |
| |
| |
| |
Problems | |
| |
| |
| |
Summary of Characters, Commands, and Functions | |
| |
| |
Answers to Selected Problems | |
| |
| |
Index | |