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
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 |
19 | |
inf |
Infinity. | 19 |
j |
Same as i. | 19 |
NaN |
Not a number. | 19 |
pi |
The number π. | 19 |
Display formats in the Command Window
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
Hyperbolic math functions
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 |
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 |
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
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
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
3.14.251.57