Matlab Commands
Matlab Commands
Input/Output Commands
disp fscanf format fprintf input ; Displays contents of an array or string. Read formatted data from a file. Controls screen-display format. Performs formatted writes to screen or file. Displays prompts and waits for input. Suppresses screen printing.
Array Commands
cat find length linspace logspace max min prod reshape size sort sum Concatenates arrays. Finds indices of nonzero elements. Computers number of elements. Creates regularly spaced vector. Creates logarithmically spaced vector. Returns largest element. Returns smallest element. Product of each column. Change size Computes array size. Sorts each column. Sums each column.
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.
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.
Plotting Commands
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.
Programming
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.
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.
Mathematical Functions
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) acoth(x) acsch(x) asech(x) asinh(x) atanh(x) cosh(x) coth(x) csch(x) sech(x) sinh(x) tanh(x) Inverse hyperbolic cosine; cosh 1 (x). Inverse hyperbolic cotangent; coth 1 (x). Inverse hyperbolic cosecant; csch 1 (x). Inverse hyperbolic secant; sech 1 (x). Inverse hyperbolic sine; sinh 1 (x). Inverse hyperbolic tangent; tanh 1 (x). Hyperbolic cosine; cosh(x). Hyperbolic cotangent; cosh(x)/sinh(x). Hyperbolic cosecant; 1/sinh(x). Hyperbolic secant; 1/cosh(x). Hyperbolic sine; sinh(x). Hyperbolic tangent; sinh(x)/cosh(x).
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
Numerical Methods
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.
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.