Matlab Commands PDF
Matlab Commands PDF
Plotting Commands
Basic xy Plotting Commands / 8 Plot Enhancement Commands / 8 Specialized Plot Commands / 8 Colors, Symbols and Line Types / 9 Three-Dimensional Plotting Commands / 9 Histogram Functions / 9
MATLAB Commands 1
Programming
Logical and Relational Operators / 10 Program Flow Control / 10 Logical Functions / 10 M-Files / 11 Timing /11
Mathematical Functions
Exponential and Logarithmic Functions / 12 Trigonometric Functions / 12 Hyperbolic Functions / 12 Complex Functions / 13 Statistical Functions / 13 Random Number Functions / 13 Numeric Functions / 13 String Functions / 13
Numerical Methods
Polynomial and Regression Functions / 14 Interpolation Functions / 14 Numerical Integration Functions / 14 Numerical Differentiation Functions / 14 ODE Solvers / 15 Predefined Input Functions / 15
MATLAB Commands 2
MATLAB Commands 3
MATLAB Commands 4
MATLAB Commands 5
Special Matrices
eye ones zeros Creates an identity matrix. Creates an array of ones. Creates an array of zeros.
Matrix Arithmetic
cross dot Computes cross products. Computes dot products.
MATLAB Commands 6
Structure Functions
fieldnames getfield isfield isstruct rmfield setfield struct Returns field names in a structure array. Returns field contents of a structure array. Identifies a structure array field. Identifies a structure array. Removes a field from a structure array. Sets contents of field. Creates structure array.
MATLAB Commands 7
Plotting Commands
Basic xy Plotting Commands
axis fplot grid plot print title xlabel ylabel Sets axis limits. Intelligent plotting of functions. Displays gridlines. Generates xy plot. Prints plot or saves plot to a file Puts text at top of plot. Adds text label to x-axis. Adds text label to y-axis.
MATLAB Commands 8
Symbol
point circle x-mark plus star diamond triangle (down) triangle (up) triangle (left) triangle (right) pentagram hexagram : -. --
Line
solid dotted dash dotted dashed
Histogram Functions
bar hist histc Creates a bar chart. Aggregates the data into equally spaced bins. Aggregates the data into unequally spaced bins.
MATLAB Commands 9
Programming
Logical and Relational Operators
== ~= < <= > >= & | ~ xor Relational operator: equal to. Relational operator: not equal to. Relational operator: less than. Relational operator: less than or equal to. Relational operator: greater than. Relational operator: greater than or equal to. Logical operator: AND. Logical operator: OR. Logical operator: NOT. Logical operator: EXCLUSIVE OR.
Logical Functions
any all find finite isnan isinf isempty isreal True if any elements are nonzero. True if all elements are nonzero. Finds indices of nonzero elements. True if elements are finite. True if elements are undefined. True if elements are infinite. True if matrix is empty. True if all elements are real.
MATLAB Commands 10
M-Files
eval feval function global nargin nargout script Interpret strings containing Matlab expressions. Function evaluation. Creates a user-defined function M-file. Define global variables. Number of function input arguments. Number of function output arguments. Script M-files
Timing
cputime clock tic, toc CPU time in seconds. Current date and time as date vector. Start, stop a stopwatch timer.
MATLAB Commands 11
Mathematical Functions
Exponential and Logarithmic Functions
exp(x) log(x) log10(x) sqrt(x) Exponential; ex. Natural logarithm; ln(x). Common (base 10) logarithm; log(x)= log10(x). Square root; x.
Trigonometric Functions
acos(x) acot(x) acsc(x) asec(x) asin(x) atan(x) atan2(y,x) cos(x) cot(x) csc(x) sec(x) sin(x) tan(x) Inverse cosine; arcos x = cos 1 (x). Inverse cotangent; arccot x = cot 1(x). Inverse cosecant; arcs x = csc 1 (x). Inverse secant; arcsec x = sec 1 (x). Inverse sine; arcsin x = sin 1 (x). Inverse tangent; arctan x = tan 1 (x). Four-quadrant inverse tangent. Cosine; cos(x). Cotangent; cot(x). Cosecant; csc(x). Secant; sec(x). Sine; sin(x). Tangent; tan(x).
Hyperbolic Functions
acosh(x) Inverse hyperbolic cosine; cosh 1 (x). acoth(x) Inverse hyperbolic cotangent; coth 1 (x). acsch(x) Inverse hyperbolic cosecant; csch 1 (x). asech(x) Inverse hyperbolic secant; sech 1 (x). asinh(x) Inverse hyperbolic sine; sinh 1 (x). atanh(x) Inverse hyperbolic tangent; tanh 1 (x). cosh(x) Hyperbolic cosine; cosh(x). coth(x) Hyperbolic cotangent; cosh(x)/sinh(x). csch(x) Hyperbolic cosecant; 1/sinh(x). sech(x) Hyperbolic secant; 1/cosh(x). sinh(x) Hyperbolic sine; sinh(x). -0.24 30 761 cm 2147 2188 2 57 re f Q Q q 66.72 31x v 43545 8 2 57 (x)
MATLAB Commands 12
Complex Functions
abs(x) angle(x) conj(x) imag(x) real(x) Absolute value; |x|. Angle of a complex number x. Complex conjugate of x. Imaginary part of a complex number x. Real part of a complex number x.
Statistical Functions
erf(x) mean median std Computes the error function erf (x). Calculates the average. Calculates the median. Calculates the standard deviation.
Numeric Functions
ceil fix floor round sign Rounds to the nearest integer toward . Rounds to the nearest integer toward zero. Rounds to the nearest integer toward - . Rounds towards the nearest integer. Signum function.
String Functions
findstr strcmp char Finds occurrences of a string. Compares strings. Creates character string array
MATLAB Commands 13
Numerical Methods
Polynomial and Regression Functions
conv deconv eig poly polyfit polyval roots Computes product of two polynomials Computes ratio of polynomials. Computes the eigenvalues of a matrix. Computes polynomial from roots. Fits a polynomial to data. Evaluates polynomial and generates error estimates. Computes polynomial roots.
Interpolation Functions
interp1 interp2 spline unmkpp Linear and cubic-spline interpolations of a function of one variable. Linear interpolation of a function of two variables. Cubic-spline interpolation. Computes the coefficients of cubic-spine polynomials.
MATLAB Commands 14
ODE Solvers
ode23 ode45 ode113 ode23s ode23t ode23b ode15s odeset Nonstiff, low-order solver. Nonstiff, medium-order solver. Nonstiff, variable-order solver. Stiff, low-order. Moderately stiff, trapezoidal rule solver. Stiff, low-order solver. Stiff, variable-order solver. Creates integrator options structure for ODE solvers.
MATLAB Commands 15
MATLAB Commands 16
MATLAB Commands 17