Appendix B

Command and Function Quick Reference

This appendix is not exhaustive; it lists most of the MATLAB commands and functions used in the text, as well as a few more.

For a complete list by category (with links to detailed descriptions) see the online documentation MATLAB: Reference: MATLAB Function Reference: Functions by Category.

The command help by itself displays a list of all the function categories (each in its own directory):

image

B.1 General purpose commands

B.1.1 Managing commands

demo Run demos
help Online help
helpwin Display categories of functions with links to each category
lookfor Keyword search through help entries
type List M-file
what Directory listing of M- and MAT-files
which Locate functions and files

B.1.2 Managing variables and the workspace

clear Clear variables and functions from memory
disp Display matrix or text
length Length of a vector
load Retrieve variables from disk
save Save workspace variables to disk
size Array dimensions
who, whos List variables in the workspace

B.1.3 Files and the operating system

beep Produce a beep sound
cd Change current working directory
delete Delete file
diary Save text of MATLAB session
dir Directory listing
edit Edit an M-file
! Execute operating system command

B.1.4 Controlling the Command Window

clc Clear Command Window
echo Echo commands in script
format Set output format for disp
home Send cursor home
more Control paged output

B.1.5 Starting and quitting MATLAB

exit Terminate MATLAB
quit Terminate MATLAB
startup M-file executed when MATLAB starts

B.2 Logical functions

all True if all elements of vector are true (non-zero)
any True if any element of vector is true
exist Check if variable or file exists
find Find indices of non-zero elements
is* Detect various states
logical Convert numeric values to logical

B.3 Language constructs and debugging

B.3.1 MATLAB as a programming language

error Display error message
eval Interpret string containing MATLAB expression
feval Function evaluation
for Repeat statements a specific number of times
global Define global variable
if Conditionally execute statements
persistent Define persistent variable
switch Switch among several cases
try Begin try block
while Repeat statements conditionally

B.3.2 Interactive input

input Prompt user for input
keyboard Invoke keyboard as a script file
menu Generate menu of choices for user input
pause Wait for user response

B.4 Matrices and matrix manipulation

B.4.1 Elementary matrices

eye Identity matrix
linspace Vector with linearly spaced elements
ones Matrix of ones
rand Uniformly distributed random numbers and arrays
randn Normally distributed random numbers and arrays
zeros Matrix of zeros
: (colon) Vector with regularly spaced elements

B.4.2 Special variables and constants

Image

B.4.3 Time and date

calendar Calendar
clock Wall clock (complete date and time)
date You’d never guess
etime Elapsed time
tic, toc Stopwatch
weekday Day of the week

B.4.4 Matrix manipulation

cat Concatenate arrays
diag Create or extract diagonal
fliplr Flip in left/right direction
flipud Flip in up/down direction
repmat Replicate and tile an array
reshape Change shape
rot90 Rotate 90°
tril Extract lower tridiagonal part
triu Extract upper tridiagonal part

B.4.5 Specialized matrices

gallery Test matrices
hilb Hilbert matrix
magic Magic square
pascal Pascal matrix
wilkinson Wilkinson’s eigenvalue test matrix

B.5 Mathematical functions

abs Absolute value
acos, acosh Inverse cosine and inverse hyperbolic cosine
acot, acoth Inverse cotangent and inverse hyperbolic cotangent
acsc, acsch Inverse cosecant and inverse hyperbolic cosecant
angle Phase angle
asec, asech Inverse secant and inverse hyperbolic secant
asin, asinh Inverse sine and inverse hyperbolic sine
atan, atanh Inverse tangent (two quadrant) and inverse hyperbolic tangent
atan2 Inverse tangent (four quadrant)
bessel Bessel function
ceil Round up
conj Complex conjugate
cos, cosh Cosine and hyperbolic cosine
cot, coth Cotangent and hyperbolic cotangent
csc, csch Cosecant and hyperbolic cosecant
erf Error function
exp Exponential
fix Round toward zero
floor Round down
gamma Gamma function
imag Imaginary part
log Natural logarithm
log2 Dissect floating point numbers into exponent and mantissa
log10 Common logarithm
mod Modulus (signed remainder after division)
rat Rational approximation
real Real part
rem Remainder after division
round Round toward nearest integer
sec, sech Secant and hyperbolic secant
sign Signum function
sin, sinh Sine and hyperbolic sine
sqrt Square root
tan, tanh Tangent and hyperbolic tangent

B.6 Matrix functions

det Determinant
eig Eigenvalues and eigenvectors
expm Matrix exponential
inv Matrix inverse
poly Characteristic polynomial
rank Number of linearly independent rows or columns
rcond Condition estimator
trace Sum of diagonal elements
{} and/ Linear equation solution

B.7 Data analysis

cumprod Cumulative product
cumsum Cumulative sum
diff Difference function
fft One-dimensional fast Fourier transform
max Largest element
mean Average value of elements
median Median value of elements
min Smallest element
prod Product of elements
sort Sort into ascending order
std Standard deviation
sum Sum of elements
trapz Trapezoidal rule for numerical integration

B.8 Polynomial functions

polyfit Fit polynomial to data
polyval Evaluate polynomial
roots Find polynomial roots

B.9 Function functions

bvp4c Solve two-point boundary value problems for ODEs
fmin Minimize function of one variable
fmins Minimize function of several variables
fzero Find zero of function of one variable
ode23, ode23s, ode45 Solve initial value problems for ODEs
quad Numerical integration

B.10 Sparse matrix functions

full Convert sparse matrix to full matrix
sparse Construct sparse matrix from non-zeros and subscripts
spy Visualize sparse matrix

B.11 Character string functions

char characters from ASCII codes
double ASCII codes of characters
lower Convert string to lower case
sprintf Write formatted data to a string
str2mat String to matrix conversion
strcat String concatenation
strcmp Compare strings
upper Convert string to upper case

B.12 File I/O functions

fclose Close one or more open files
feof Test for end-of-file
fopen Open file or obtain information about open files
fprintf Write formatted data to file
fread Read binary data from file
fscanf Read formatted data from file
fseek Set file position indicator
ftell Get file position indicator
fwrite Write binary data to file

B.13 Graphics

B.13.1 2-D

bar Bar graph
grid Grid lines
hist Histogram plot
loglog Log-log scale plot
plot Linear plot
polar Polar co-ordinate plot
semilogx Semi-log scale plot
semilogy Semi-log scale plot
text Text annotation
title Graph title
xlabel x-axis label
ylabel y-axis label
zoom Zoom in and out on a 2-D plot

B.13.2 3-D

clabel Contour plot elevation labels
comet3 Animated 3-D plot
contour Contour plot in 2-D
contour3 Contour plot in 3-D
mesh 3-D mesh surface
meshc 3-D mesh surface with contour plot
meshgrid x and y arrays for 3-D plots
plot3 Line plot in 3-D
quiver Quiver plot.
surf Shaded surface
surfl Shaded surface with lighting
view Rotation of 3-D figure
zlabel z-axis label.

B.13.3 General

axes Create axes object
axis Control axis scaling and appearance
cla Clear axes
clf Clear current figure
colorbar Display color bar (color scale)
colormap Set the color look-up table (list of color maps)
drawnow Complete any pending drawing
figure Create figure (graph) windows
fplot Plot a function
gca Get current axes handle
gcf Get current figure handle
gco Return handle of current graphics object
get Get graphics object properties
ginput Graphical input from a mouse or cursor
gtext Mouse placement of text
set Set graphics object properties
subplot Create axes in tiled positions
..................Content has been hidden....................

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