You are on page 1of 7

cross Computes cross products

Dot Computes dot products


cell Creates cell array
Fieldnames Returns names in a structure array
Rmfield Removes a field from a structural array
Struct Creates a structure array
axis Set axis limits and other axis properties
Fplot Intelligent plotting of functions
Ginput Reads coordinates of the cursor position
Grid Displays grid lines
plot Generates xy plot
Title Puts text at top of plot
Xlabel Adds text label to x-axis
Ylabel Adds text label to y-axis
Gtext Enables label placement by mouse
Hold Freezes current plot
Legend Places legend by mouse
Subplot Creates plot in subwindows
Text Places string in gure
Bar Creates bar chart
Loglog Creates log-log plot
Plotyy Enables plotting on the left and right axes
semilogx Creates semilog plot (logarithmic abscissa)
Semilogy Creates semilog plot (logarithmic ordinates)
Break Terminates execution of a loop
case Provides alternate excecution paths within
switch stracture
continue Pases control to the next iteration of a for
or while loop
else Delineates alternate block of statements
Eleseif Conditionally executes statements
end Terminates for while, and if statements
For Repeats statements a specific number of
times
If Executes statements conditionally
Otherwise Provides optional control within a switch
structure
Switch Directs program excecution by comparing
input with case expression
While Repeats statements and indefinite number
of times
Bar Creates a bar chart
Hist Aggregates the data into bins
Mean Calculates the mean
Median Calculates the median
Polyfit Fits a polynomial to data
Polyval Evaluated a polynomial and generates error
estimates
Roots Computes the roots of a polynomial from
its coefficient
Interp1 Linear and cubic spline interpolation of a
function of one variable
Spline Cubic spline interpolation
Polyint Intergration of a polynomial
trapz Numerical integration with the trapezoidal
rule
Triplequad Numerical integration of a triple integral

Logical and relational operators


== Relational operator: equal to. 155
~= Relational operator: not equal to. 155
< Relational operator: less than. 155
<= Relational operator: less than or equal to. 155
> Relational operator: greater than. 155
>= Relational operator: greater than or equal to. 155
& Logical operator: AND. 158
&& Short-circuit AND. 158
| Logical operator: OR. 158
|| Short-circuit OR. 158
~ Logical operator: NOT. 158

Special variables and constants


ans Most recent answer. 14
eps Accuracy of oating-point precision. 14
i,j The imaginary unit . 14
Inf In nity . 14
NaN Unde ned numerical result (not a number). 14
pi The number !. 14

Commands for managing a session


clc Clears Command window. 12
clear Removes variables from memory. 12
doc Displays documentation. 38
exist Checks for existence of le or variable. 12
global Declares variables to be global. 124
help Displays Help text in the Command window. 38
helpwin Displays Help text in the Help browser. 38
lookfor Searches Help entries for a keyword. 38
quit Stops MATLAB. 12
who Lists current variables. 12
whos Lists current variables (long display). 12

System and le commands


cd Changes current directory. 23
date Displays current date. 122
dir Lists all les in current directory . 23
load Loads workspace variables from a le. 21
path Displays search path. 23
pwd Displays current directory. 23
save Saves workspace variables in a le. 21
type Displays contents of a le. 38
what Lists all MATLAB les. 23
wk1read Reads .wk1 spreadsheet le. 138
xlsread Reads .xls spreadsheet le. 135

Input/output commands
disp Displays contents of an array or string. 31
format Controls screen display format. 14, 31
fprintf Performs formatted writes to screen or le. 549
input Displays prompts and waits for input. 31, 171
menu Displays a menu of choices. 31
; Suppresses screen printing. 12

Numeric display formats


format short Four decimal digits (default). 14, 31
format long 16 decimal digits. 14, 31
format short e Five digits plus exponent. 14, 31
format long e 16 digits plus exponent. 14, 31
format bank Two decimal digits. 14, 31
format + Positive, negative, or zero. 14, 31
format rat Rational approximation. 14, 31
format compact Suppresses some line feeds. 14, 31
format loose Resets to less compact display mode. 14, 31

Array functions
cat Concatenates arrays. 64
nd Finds indices of nonzero elements. 60, 161
length Computes number of elements. 19
linspace Creates regularly spaced vector. 60
logspace Creates logarithmically spaced vector. 60
max Returns largest element. 60
min Returns smallest element. 60
size Computes array size. 60
sort Sorts each column. 60, 296
sum Sums each column. 60

Special matrices
eye Creates an identity matrix. 83
ones Creates an array of 1s. 83
zeros Creates an array of 0 s. 83

Matrix functions for solving linear equations


det Computes determinant of an array. 333
inv Computes inverse of a matrix. 333
pinv Computes pseudoinverse of a matrix. 342
rank Computes rank of a matrix. 335
rref Computes reduced row echelon form. 345

Exponential and logarithmic functions


exp(x) Exponential; ex. 21, 114
log(x) Natural logarithm; In x. 114
log10(x) Common (base 10) logarithm; log x " log10 x. 114
sqrt(x) Square root; 114

Complex functions
abs(x) Absolute value; 114
angle(x) Angle of a complex number x. 114
conj(x) Complex conjugate of x. 114
imag(x) Imaginary part of a complex number x. 114
real(x) Real part of a complex number x. 114

Matrix functions for solving linear equations


det Computes determinant of an array. 333
inv Computes inverse of a matrix. 333
pinv Computes pseudoinverse of a matrix. 342
rank Computes rank of a matrix. 335
rref Computes reduced row echelon form. 345

Exponential and logarithmic functions


exp(x) Exponential; ex. 21, 114
log(x) Natural logarithm; In x. 114
log10(x) Common (base 10) logarithm; log x " log10 x. 114
sqrt(x) Square root; 114

Complex functions
abs(x) Absolute value; 114
angle(x) Angle of a complex number x. 114
conj(x) Complex conjugate of x. 114
imag(x) Imaginary part of a complex number x. 114
real(x) Real part of a complex number x. 114

Numeric functions
ceil Rounds to the nearest integer toward 114
fix Rounds to the nearest integer toward zero. 114
floor Rounds to the nearest integer toward # 114
round Rounds toward the nearest integer. 114
sign Signum function. 114

Trigonometric functions
acos(x) Inverse cosine; arccos x " cos#1x. 21, 118
acot(x) Inverse cotangent; arccot x " cot#1x. 118
acsc(x) Inverse cosecant; arccsc x " csc#1x. 118
asec(x) Inverse secant; arcsec x " sec#1x. 118
asin(x) Inverse sine; arcsin x " sin#1x. 21, 118
atan(x) Inverse tangent; arctan x " tan#1x. 21, 118
atan2(y,x) Four-quadrant inverse tangent. 118
cos(x) Cosine; cos x. 21, 118
cot(x) Cotangent; cot x. 118
csc(x) Cosecant; csc x. 118
sec(x) Secant; sec x. 118
sin(x) Sine; sin x. 118
tan(x) Tangent; tan x. 118

Hyperbolic functions
acosh(x) Inverse hyperbolic cosine; cosh#1x. 119
acoth(x) Inverse hyperbolic cotangent; coth#1x. 119
acsch(x) Inverse hyperbolic cosecant; csch#1x. 119
asech(x) Inverse hyperbolic secant; sech#1x. 119
asinh(x) Inverse hyperbolic sine; sinh#1x. 119
atanh(x) Inverse hyperbolic tangent; tanh#1x. 119
cosh(x) Hyperbolic cosine; cosh x. 119
coth(x) Hyperbolic cotangent; cosh x /sinh x. 119
csch(x) Hyperbolic cosecant; 1$sinh x. 119
sech(x) Hyperbolic secant; 1$cosh x. 119
sinh(x) Hyperbolic sine; sinh x. 119
tanh(x) Hyperbolic tangent; sinh x / cosh x. 119

Polynomial functions

conv Computes product of two polynomials. 86


deconv Computes ratio of polynomials. 86
eig Computes the eigenvalues of a matrix. 397
poly Computes polynomial from roots. 86
poly t Fits a polynomial to data. 273
polyval Evaluates polynomial. 225
roots Computes polynomial roots. 86

Logical functions
any True if any elements are nonzero. 161
all True if all elements are nonzero. 161
nd Finds indices of nonzero elements. 161
nite True if elements are nite. 161
ischar True if elements are a character array. 161
isinf True if elements are in nite. 161
isempty True if matrix is empty. 161
isnan True if elements are unde ned. 161
isreal True if all elements are real. 161
isnumeric True if elements have numeric values. 161
logical Converts a numeric array to a logical array. 161
xor Exclusive OR. 161

Miscellaneous mathematical functions


cross Computes cross products. 85
dot Computes dot products. 85
function Creates a user-de ned function. 119
nargin Number of function input arguments. 170
nargout Number of function output arguments. 170

Cell and structure functions


cell Creates cell array. 90
eldnames Returns eld names in a structure array . 94
is eld Identi es a structure array eld. 94
isstruct Identi es a structure array . 94
rm eld Removes a eld from a structure array . 94
struct Creates a structure array. 93

Basic xy plotting commands


axis Sets axis limits and other axis properties. 222, 225
cla Clears the axes. 539
fplot Intelligent plotting of functions. 223, 225
ginput Reads coordinates of the cursor position. 25
grid Displays grid lines. 225
plot Generates xy plot. 23, 232
print Prints plot or saves plot to a le. 225
title Puts text at top of plot. 225
xlabel Adds text label to x axis. 225
ylabel Adds text label to y axis. 225

Plot enhancement commands


colormap Sets the color map of the current gure. 539
gtext Enables label placement by mouse. 232
hold Freezes current plot. 232
legend Places legend by mouse. 230
subplot Creates plots in subwindows. 232
text Places string in gure. 232

Specialized plot functions


bar Creates bar chart. 235, 295
loglog Creates log-log plot. 235
plotyy Enables plotting on left and right axes. 235
polar Creates polar plot. 235
semilogx Creates semilog plot (logarithmic abscissa). 235
semilogy Creates semilog plot (logarithmic ordinate). 235
stairs Creates stairs plot. 235
stem Creates stem plot. 235

Three-dimensional plotting functions


contour Creates contour plot. 248
mesh Creates three-dimensional mesh surface plot. 248
meshc Same as mesh with contour plot underneath. 248
meshgrid Creates rectangular grid. 247
meshz Same as mesh with vertical lines underneath. 249
plot3 Creates three-dimensional plots from lines and points. 246
shading Speci es type of shading. 539
surf Creates shaded three-dimensional mesh surface plot. 248
surfc Same as surf with contour plot underneath. 248
sur Same as surf with lighting. 539
view Sets the angle of the view. 539
waterfall Same as mesh with mesh lines in one direction. 249
zlabel Adds text label to z axis. 248

Program ow control
break Terminates execution of a loop. 176
case Provides alternate execution paths within switch structure. 188
continue Passes control to the next iteration of a for or while loop. 276
else Delineates alternate block of statements. 166
elseif Conditionally executes statements. 168
end Terminates for, while, and if statements. 166
for Repeats statements a speci c number of times. 172
if Executes statements conditionally. 165
otherwise Provides optional control within a switch structure. 188
switch Directs program execution by comparing input with 188
case expressions.
while Repeats statements an inde nite number of times. 183

Optimization and root- nding functions


fminbnd Finds the minimum of a function of one variable. 128
fminsearch Finds the minimum of a multivariable function. 128
fzero Finds the zero of a function. 128

Histogram functions
bar Creates a bar chart. 235, 295
hist Aggregates the data into bins. 300

Statistical functions
cumsum Computes the cumulative sum across a row. 303
erf Computes the error function erf(x). 305
mean Calculates the mean. 296
median Calculates the median. 296
std Calculates the standard deviation. 304

Random number functions


rand Generates uniformly distributed random numbers 309
between 0 and 1; sets and retrieves the state.
randn Generates normally distributed random numbers; 309
sets and retrieves the state.
randperm Generates random permutation of integers. 309

Polynomial functions
poly Computes the coef cients of a polynomial from its roots. 86
polyfit Fits a polynomial to data. 273
polyval Evaluates a polynomial and generates error estimates. 273
roots Computes the roots of a polynomial from its coef cients. 86

Interpolation functions
interp1 Linear and cubic spline interpolation of a function of 320
one variable.
interp2 Linear interpolation of a function of two variables. 317
spline Cubic spline interpolation. 320
unmkpp Computes the coef cients of cubic spline polynomials. 320

Numerical integration functions


dblquad Numerical integration of a double integral. 372
polyint Integration of a polynomial. 371
quad Numerical integration with adaptive Simpsons rule. 371
quadl Numerical integration with Lobatto quadrature. 371
trapz Numerical integration with the trapezoidal rule. 371
triplequad Numerical integration of a triple integral. 371

Numerical differentiation functions


del2 Computes the Laplacian from data. 382
diff(x) Computes the differences between adjacent 329, 382
elements in the vector x.
gradient Computes the gradient from data. 382
polyder Differentiates a polynomial, a polynomial product, 382
or a polynomial quotient.

You might also like