Appendix: Summary of Characters, Commands, and Functions

The following tables list MATLAB’s characters, commands, and functions that are covered in the book. The items are grouped by subjects.

Characters and arithmetic operators

Character Description Page
+ Addition. 11, 64
– Subtraction. 11, 64
* Scalar and array multiplication. 11, 65
.* Element-by-element multiplication of arrays. 72
/ Right division. 11, 71
Left division. 11, 70
./ Element-by-element right division. 72
. Element-by-element left division. 72
^ Exponentiation. 11
.^ Element-by-element exponentiation. 72
: Colon; creates vectors with equally spaced elements, represents range of elements in arrays. 37, 44
= Assignment operator. 16
( ) Parentheses; sets precedence, encloses input arguments in functions and subscripts of arrays. 11, 42, 44, 224
[ ] Brackets; forms arrays. encloses output arguments in functions. 37, 38, 39, 224
, Comma; separates array subscripts and function arguments, separates commands in the same line. 9, 17, 42-45, 224
; Semicolon; suppresses display, ends row in array. 10, 39
′ Single quote; matrix transpose, creates string. 41, 53-55
... Ellipsis; continuation of line. 10
% Percent; denotes a comment, specifies output format. 10

Relational and logical operators

Character Description Page
< Less than 176
> Greater than. 176
<= Less than or equal. 176
>= Greater than or equal. 176
== Equal. 176
~= Not equal. 176
& Logical AND. 179
| Logical OR. 179
~ Logical NOT. 179

Managing commands

Character Description Page
cd Changes current directory. 24
clc Clears the Command Window. 10
clear Removes all variables from the memory. 19
clear x y z Removes variables x, y, and z from the memory. 19
close Closes the active Figure Window. 158
fclose Closes a file. 109
figure Opens a Figure Window. 158
fopen Opens a file. 108
global Declares global variables. 227
help Displays help for MATLAB functions. 226
iskeyword Displays keywords. 19
lookfor Search for specified word in all help entries. 226
who Displays variables currently in the memory. 20, 96
whos Displays information on variables in the memory. 20, 96

Predefined variables

Variable Description Page
ans Value of last expression. 19
eps The smallest difference between two numbers. 19
i images 19
inf Infinity. 19
j Same as i. 19
NaN Not a number. 19
pi The number π. 19

Display formats in the Command Window

Command Description Page
format bank Two decimal digits. 13
format compact Eliminates empty lines. 13
format long Fixed-point format with 14 decimal digits. 13
format long e Scientific notation with 15 decimal digits. 13
format long g Best of 15-digit fixed or floating point. 13
format loose Adds empty lines. 13
format short Fixed-point format with 4 decimal digits. 13
format short e Scientific notation with 4 decimal digits. 13
format short g Best of 5-digit fixed or floating point. 13

Elementary math functions

Funtion Description Page
abs Absolute value. 15
exp Exponential. 14
factorial The factorial function. 15
log Natural logarithm. 15
log10 Base 10 logarithm. 15
nthroot Real nth root or a real number. 14
sqrt Square root. 14

Trigonometric math functions

Images

Hyperbolic math functions

Images

Rounding

Character Description Page
ceil Round towards infinity. 16
fix Round towards zero. 15
floor Round towards minus infinity. 16
rem Returns the remainder after x is divided by y. 16
round Round to the nearest integer. 15
sign Signum function. 16

Creating arrays

Function Description Page
diag Creates a diagonal matrix from a vector. Creates a vector from the diagonal of a matrix. 50
eye Creates a unit matrix. 40, 68
linspace Creates equally spaced vector. 38
ones Creates an array with ones. 40
rand Creates an array with random numbers. 77, 78
randi Creates an array with random integers. 78
randn Creates an array with normally distributed numbers. 79
randperm Creates vector with permutation of integers. 78
zeros Creates an array with zeros. 40

Handling arrays

Function Description Page
length Number of elements in the vector. 49
reshape Rearrange a matrix. 49
size Size of an array. 49

Array functions

Function Description Page
cross Calculates cross product of two vectors. 77
det Calculates determinant. 70, 77
dot Calculates scalar product of two vectors. 66, 77
inv Calculates the inverse of a square matrix. 69, 77
max Returns maximum value. 76
mean Calculates mean value. 76
median Calculates median value. 76
min Returns minimum value. 76
sort Arranges elements in ascending order. 76
std Calculates standard deviation. 77
sum Calculates sum of elements. 76

Input and output

Command Description Page
disp Displays output. 101
fprintf Displays or saves output. 103-110
input Prompts for user input. 99
load Retrieves variables to the workspace. 112
save Saves the variables in the workspace. 111
uiimport Starts the Import Wizard 116
xlsread Imports data from Excel 114

Input and output

Command Description Page
xlswrite Exports data to Excel 115

Two-dimensional plotting

Command Description Page
bar Creates a vertical bar plot. 152
barh Creates a horizontal bar plot. 152
errorbar Creates a plot with error bars. 151
fplot Plots a function. 140
hist Creates a histogram. 154-156
hold off Ends hold on. 142
hold on Keeps current graph open. 142
line Adds curves to existing plot. 143
loglog Creates a plot with log scale on both axes. 149
pie Creates a pie plot. 153
plot Creates a plot. 134
polar Creates a polar plot. 156
semilogx Creates a plot with log scale on the x axis. 149
semilogy Creates a plot with log scale on the y axis. 149
stairs Creates a stairs plot. 153
stem Creates a stem plot. 153

Three-dimensional plotting

Command Description Page
bar3 Creates a vertical 3-D bar plot. 331
contour Creates a 2-D contour plot. 330
contour3 Creates a 3-D contour plot. 330
cylinder Plots a cylinder. 331
mesh Creates a mesh plot. 327, 328
meshc Creates a mesh and a contour plot. 329
meshgrid Creates a grid for a 3-D plot. 325
meshz Creates a mesh plot with a curtain. 329
pie3 Creates a pie plot. 332
plot3 Creates a plot. 323
pol2cart Convert the polar coordinates grid to a grid in Cartesian coordinates. 333
scatter3 Creates a scatter plot. 332
sphere Plots a sphere. 331
stem3 Creates a stem plot 332
surf Creates a surface plot. 327, 329
surfc Creates a surface and a contour plot. 329
surfl Creates a surface plot with lighting. 330
waterfall Creates a mesh plot with a waterfall effect. 330

Formatting plots

Command Description Page
axis Sets limits to axes. 147
colormap Sets color. 328
grid Adds grid to a plot. 148, 328
gtext Adds text to a plot. 145
legend Adds legend to a plot. 145
subplot Creates multiple plots on one page. 157
text Adds text to a plot. 145
title Adds title to a plot. 144
view Controls the viewing direction of a 3-D plot. 333
xlabel Adds label to x axis. 144
ylabel Adds label to y axis. 144

Math functions (create, evaluate, solve)

Command Description Page
feval Evaluates the value of a math function. 238
fminbnd Determines the minimum of a function. 298
fzero Solves an equation with one variable. 296

Numerical integration

Command Description Page
quad Integrates a function. 300
quadl Integrates a function. 301
trapz Integrates a function. 302

Ordinary differential equation solvers

Command Description Page
ode113 Solves a first order ODE. 304
ode15s Solves a first order ODE. 305
ode23 Solves a first order ODE. 304
ode23s Solves a first order ODE. 305
ode23t Solves a first order ODE. 305
ode23tb Solves a first order ODE. s305
ode45 Solves a first order ODE. 304

Logical Functions

Function Description Page
all Determines if all array elements are nonzero. 182
and Logical AND. 181
any Determines if any array elements are nonzero. 182
find Finds indices of certain elements of a vector. 182
not Logical NOT. 181
or Logical OR. 181
xor Logical exclusive OR. 182

Flow control commands

Command Description Page
break Terminates execution of a loop. 202
case Conditionally execute commands. 189
continue Terminates a pass in a loop. 202
else Conditionally execute commands. 186
elseif Conditionally execute commands. 187
end Terminates conditional statements and loops. 184, 189, 193, 197
for Repeats execution of a group of commands. 193
if Conditionally execute commands. 184
otherwise Conditionally execute commands. 189
switch Switches among several cases based on expression. 189
while Repeats execution of a group of commands. 197

Polynomial functions

Function Description Page
conv Multiplies polynomials. 265
deconv Divides polynomials. 265
poly Determines coefficients of a polynomial. 264
polyder Determines the derivative of a polynomial. 266
polyval Calculates the value of a polynomial. 262
roots Determines the roots of a polynomial. 263

Curve fitting and interpolation

Function Description Page
interp1 One-dimensional interpolation. 267
polyfit Curve fit polynomial to set of points. 269

Symbolic Math

Function Description Page
collect Collects terms in an expression. 354
diff Differentiates an equation. 363
double Converts number from symbolic form to numerical form 352
dsolve Solves an ordinary differential equation. 367
expand Expands an expression. 355
ezplot Plots an expression. 369
factor Factors to product of lower order polynomials. 355
findsym Displays the symbolic variables in an expression. 353
int integrates an expression. 365
pretty Displays expression in math format. 357
simple Finds a form of an expression with fewest characters. 357
simplify Simplifies an expression. 356
solve Solves a single equation, or a system of equations. 358
subs Substitutes numbers in an expression. 372
sym Creates symbolic object. 348
syms Creates symbolic object. 350
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.182.221