This action might not be possible to undo. Are you sure you want to continue?

BooksAudiobooksComicsSheet Music### Categories

### Categories

### Categories

Editors' Picks Books

Hand-picked favorites from

our editors

our editors

Editors' Picks Audiobooks

Hand-picked favorites from

our editors

our editors

Editors' Picks Comics

Hand-picked favorites from

our editors

our editors

Editors' Picks Sheet Music

Hand-picked favorites from

our editors

our editors

Top Books

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Audiobooks

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Comics

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Sheet Music

What's trending, bestsellers,

award-winners & more

award-winners & more

Welcome to Scribd! Start your free trial and access books, documents and more.Find out more

Dr. Brian Vick

Mechanical Engineering Department Virginia Tech General Purpose Commands

Operators and Special Characters / 3 Commands for Managing a Session / 3 Special Variables and Constants / 4 System and File Commands / 4

**Input/Output and Formatting Commands
**

Input/Output Commands / 5 Format Codes for fprintf and fscanf / 5 Numeric Display Formats / 5

**Vector, Matrix and Array Commands
**

Array Commands / 6 Special Matrices / 6 Matrix Arithmetic / 6 Matrix Commands for Solving Linear Equations / 6 Cell Array Functions / 7 Structure Functions / 7

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 Symbolic Math Toolbox Functions for Creating and Evaluating Symbolic Expressions / 16 Functions for Manipulating Symbolic Expressions / 16 Symbolic Calculus Functions / 16 Symbolic Solution of Algebraic and Transcendental Equations / 17 Symbolic Solution of Differential Equations / 17 Laplace Transform Functions / 17 Symbolic Linear Algebra Functions / 17 MATLAB Commands – 2 .

Scalar and matrix multiplication operator. Quote sign and transpose operator. separates columns and suppresses display. Checks for existence of file or variable. overrides precedence. Scalar and matrix exponentiation operator. encloses function arguments and array indices. Decimal point. Left-division operator. . line-continuation operator. Stops MATLAB. generates regularly spaced elements and represents an entire row or column. Searches for a help topic. Array exponentiation operator. Colon. Right-division operator. Array multiplication operator. MATLAB Commands – 3 . Removes variables from memory. designates a comment and specifies formatting.* ^ . separates statements and elements in a row./ : ( ) [ ] . Array left-division operator. % _ . Percent sign.\ . Comma. Ellipsis. Array right-division operator. subtraction operator. … . Parentheses.General Purpose Commands Operators and Special Characters + * . addition operator._ = Plus. Minus. enclosures array elements. Assignment (replacement) operator. Searches help entries for a keyword. Lists current variables (long display). Nonconjugated transpose operator. Brackets.^ \ / . Declares variables to be global. Commands for Managing a Session clc clear exist global help lookfor quit who whos Clears Command window. Lists current variables. Semicolon.

Infinity.1. The imaginary unit . Switches on/off diary file recording. Lists all files in current directory.wk1 spreadsheet file. Saves workspace variables in a file.Special Variables and Constants ans eps i. Undefined numerical result (not a number). System and File Commands cd date delete diary dir load path pwd save type what wklread Changes current directory. Accuracy of floating-point precision. Displays current date. Deletes a file. Reads . The number p . Displays current directory. Lists all MATLAB files in the current directory. Displays search path. MATLAB Commands – 4 . Loads workspace variables from a file. Displays contents of a file.j Inf NaN pi Most recent answer.

MATLAB Commands – 5 . Resets to less compact display mode. Insert a new line in the output string. or zero. Format as an integer. Numeric Display Formats format format format format format format format format format short long short e long e bank + rat compact loose Four decimal digits (default). Displays prompts and waits for input. 16 decimal digits. Five digits plus exponent. Suppresses screen printing. Controls screen-display format. Format as a floating point value in scientific notation. Format as a floating point value. Positive. negative. Suppresses some line feeds. Insert a tab in the output string. Performs formatted writes to screen or file. Format Codes for fprintf and fscanf %s %d %f %e %g \n \t Format as a string. Two decimal digits.Input/Output and Formatting Commands Input/Output Commands disp fscanf format fprintf input . Rational approximation. 16 digits plus exponents. Read formatted data from a file. Displays contents of an array or string. Format in the most compact form: %f or %e.

Computes dot products. Computes pseudoinverse of a matrix. Special Matrices eye ones zeros Creates an identity matrix. Returns smallest element. Matrix and Array Commands Array Commands cat find length linspace logspace max min prod reshape size sort sum Concatenates arrays. Change size Computes array size. Creates an array of ones. Returns largest element.Vector. Product of each column. Matrix Arithmetic cross dot Computes cross products. Matrix Commands for Solving Linear Equations det inv pinv rank rref Computes determinant of an array. Finds indices of nonzero elements. Computers number of elements. Computes rank of a matrix. Sums each column. Computes inverse of a matrix. Creates regularly spaced vector. Creates an array of zeros. Computes reduced row echelon form. Creates logarithmically spaced vector. MATLAB Commands – 6 . Sorts each column.

Cell Array Functions cell celldisp cellplot num2cell deal iscell Creates cell array. Identifies cell array. Identifies a structure array field. Matches input and output lists. Structure Functions fieldnames getfield isfield isstruct rmfield setfield struct Returns field names in a structure array. Displays cell array. Identifies a structure array. Returns field contents of a structure array. Displays graphical representation of cell array. Removes a field from a structure array. Creates structure array. Sets contents of field. MATLAB Commands – 7 . Converts numeric array to cell array.

Creates semilog plot (logarithmic ordinate). Places string in figure. Creates stem plot. Intelligent plotting of functions. Enables label placement by mouse. Creates plots in subwindows. Specifies properties of objects such as axes. Prints plot or saves plot to a file Puts text at top of plot. Generates xy plot. Creates polar plot. Opens a new figure window. Specialized Plot Commands bar loglog polar semilogx semilogy stairs stem Creates bar chart. Creates semilog plot (logarithmic abscissa). Freezes current plot. Legend placement by mouse. Closes the current plot. Displays gridlines. Closes all plots.Plotting Commands Basic xy Plotting Commands axis fplot grid plot print title xlabel ylabel Sets axis limits. Redraws current figure window. Creates log-log plot. Creates stairs pot. MATLAB Commands – 8 . Plot Enhancement Commands axes close close all figure gtext hold legend refresh set subplot text Creates axes objects. Adds text label to y-axis. Adds text label to x-axis.

Same as mesh with vertical lines underneath. Creates three-dimensional mesh surface plot. MATLAB Commands – 9 . Creates shaded three-dimensional mesh surface plot. Aggregates the data into unequally spaced bins. -- Line solid dotted dash dotted dashed Three-Dimensional Plotting Commands contour mesh meshc meshz plot3 surf surfc meshgrid waterfall zlabel Creates contour plot. Same as surf with contour plot underneath.Colors. Adds text label to z-axis. Creates rectangular grid. Same as mesh with contour plot underneath. o x + * d v ^ < > p h Symbol point circle x-mark plus star diamond triangle (down) triangle (up) triangle (left) triangle (right) pentagram hexagram : -. Histogram Functions bar hist histc Creates a bar chart. Aggregates the data into equally spaced bins. Creates three-dimensional plots from lines and points. Symbols and Line Types Color y m c r g b w k yellow magenta cyan red green blue white black . Same as mesh with mesh lines in one direction.

Delineates alternate block of statements. Display error messages. Display a warning message. while. Program Flow Control break case else elseif end error for if otherwise return switch warning while Terminates execution of a loop. Conditionally executes statements. Relational operator: greater than. Repeats statements an indefinite number of times. MATLAB Commands – 10 . True if elements are infinite. True if all elements are nonzero. Directs program execution by comparing point with case expressions. True if all elements are real. Relational operator: less than. Relational operator: greater than or equal to. Terminates for. Relational operator: less than or equal to. Provides alternate execution paths within switch structure. Default part of switch statement. True if elements are undefined. True if matrix is empty. and if statements. True if elements are finite. Repeats statements a specific number of times Executes statements conditionally. Logical operator: EXCLUSIVE OR. Logical Functions any all find finite isnan isinf isempty isreal True if any elements are nonzero.Programming Logical and Relational Operators == ~= < <= > >= & | ~ xor Relational operator: equal to. Finds indices of nonzero elements. Logical operator: NOT. Logical operator: OR. Relational operator: not equal to. Logical operator: AND. Return to the invoking function.

Creates a user-defined function M-file. Script M-files Timing cputime clock tic. Number of function output arguments. Start. Define global variables. Number of function input arguments. toc CPU time in seconds. Current date and time as date vector. Function evaluation. stop a stopwatch timer.M-Files eval feval function global nargin nargout script Interpret strings containing Matlab expressions. MATLAB Commands – 11 .

Cosecant. cosh(x). Inverse hyperbolic sine. Hyperbolic cotangent. coth –1 (x).Mathematical Functions Exponential and Logarithmic Functions exp(x) log(x) log10(x) sqrt(x) Exponential. arctan x = tan –1 (x). Inverse secant. Inverse hyperbolic secant. Inverse hyperbolic cotangent. sin(x). cosh –1 (x). arcs x = csc –1 (x). Four-quadrant inverse tangent. Sine. Inverse cosecant. log(x)= log10(x). arcsec x = sec –1 (x). arccot x = cot –1(x). arcsin x = sin –1 (x). cot(x).x) cos(x) cot(x) csc(x) sec(x) sin(x) tan(x) Inverse cosine. sinh(x). tanh –1 (x). 1/cosh(x). Hyperbolic secant. Inverse sine. ex. Trigonometric Functions acos(x) acot(x) acsc(x) asec(x) asin(x) atan(x) atan2(y. Common (base 10) logarithm. Square root. Hyperbolic tangent. tan(x). Inverse tangent. sinh –1 (x). sinh(x)/cosh(x). Hyperbolic cosecant. csc(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. MATLAB Commands – 12 . arcos x = cos –1 (x). Cotangent. cosh(x)/sinh(x). sech –1 (x). x. csch –1 (x). Cosine. Natural logarithm. Inverse cotangent. 1/sinh(x). cos(x). Hyperbolic sine. ln(x). sec(x). Hyperbolic cosine. Inverse hyperbolic cosecant. Tangent. Secant. Inverse hyperbolic tangent.

•. Statistical Functions erf(x) mean median std Computes the error function erf (x). String Functions findstr strcmp char Finds occurrences of a string. Real part of a complex number x. Calculates the average. Rounds towards the nearest integer. Numeric Functions ceil fix floor round sign Rounds to the nearest integer toward •.Complex Functions abs(x) angle(x) conj(x) imag(x) real(x) Absolute value. Calculates the standard deviation. Calculates the median. Imaginary part of a complex number x. Compares strings. Random Number Functions rand randn Generates uniformly distributed random numbers between 0 and 1. Rounds to the nearest integer toward . Rounds to the nearest integer toward zero. Generates normally distributed random numbers. |x|. Creates character string array MATLAB Commands – 13 . Signum function. Angle of a complex number x. Complex conjugate of x.

Cubic-spline interpolation. a polynomial product. or a polynomial quotient. Root Finding and Minimization fmin fmins fzero Finds minimum of single-variable function. Interpolation Functions interp1 interp2 spline unmkpp Linear and cubic-spline interpolations of a function of one variable. Computes polynomial from roots. Finds minimum of multivariable function. Linear interpolation of a function of two variables. Numerical integration with adaptive Lobatto quadrature. Differentiates a polynomial.Numerical Methods Polynomial and Regression Functions conv deconv eig poly polyfit polyval roots Computes product of two polynomials Computes ratio of polynomials. Finds zero of single-variable function. Computes the eigenvalues of a matrix. Computes polynomial roots. Computes the coefficients of cubic-spine polynomials. MATLAB Commands – 14 . Fits a polynomial to data. Numerical Integration Functions quad quadl trapz Numerical integration with adaptive Simpson’s rule. Numerical Differentiation Functions diff(x) polyder Computes the difference between adjacent elements in the vector x. Numerical integration with the trapezoidal rule. Evaluates polynomial and generates error estimates.

variable-order solver. Predefined Input Functions gensig sawtooth square stepfun Generates a periodic sine. trapezoidal rule solver. Stiff. low-order solver. square. variable-order solver. Generates a step function input. medium-order solver. low-order. MATLAB Commands – 15 . low-order solver. Stiff. Moderately stiff. or pulse input. Creates integrator options structure for ODE solvers. Generates a square wave input.ODE Solvers ode23 ode45 ode113 ode23s ode23t ode23b ode15s odeset Nonstiff. Generates a periodic sawtooth input. Nonstiff. Nonstiff. Stiff.

Symbolic Calculus Functions diff Dirac Heaviside int limit symsum taylor Returns the derivative of an expression. Converts an expression to numeric form. Creates one or more symbolic variables. Generates a plot of a symbolic expression. Expands an expression by carrying out jpowers. Returns the symbolic summation of an expression. Returns the Taylor series of a function. Factors an expression. Returns the numerator and denominator of an expression.Symbolic Math Toolbox Functions for Creating and Evaluating Symbolic Expressions class digits double ezplot findsym numden sym syms vpa Returns the class of an expression. Functions for Manipulating Symbolic Expressions collect expand factor poly2sym pretty simple simplify subs sym2poly Collects coefficients of like powers in an expression. Returns the integral of an expression. Sets the number of decimal digits used to do variable precision arithmetic. Converts a polynomial coefficient vector to a symbolic polynomial. Converts an expression to a polynomial coefficient vector. Sets the number of digits used to evaluate expressions. Returns the limit of an expression. Displays an expression in a form that resembles typeset mathematics. Creates a symbolic variable. Substitutes variables or expressions. Heaviside function (unit step). Searches for the shortest form of an expression. MATLAB Commands – 16 . Simplifies an expression using Maple’s simplification rules. Finds the symbolic variables in a symbolic expression. Dirac delta function (unit impulse).

Returns the inverse of a matrix.Symbolic Solution of Algebraic and Transcendental Equations solve Solves symbolic equations. Symbolic Linear Algebra Functions det eig inv poly Returns the determinant of a matrix. Returns the characteristic polynomial of a matrix. Symbolic Solution of Differential Equations dsolve Returns a symbolic solution of a differential equation or set of equations. Laplace Transform Functions ilaplace laplace Returns the inverse Laplace transform. Returns the Laplace transform. MATLAB Commands – 17 . Returns the eigenvalues (characteristic roots) of a matrix.

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue listening from where you left off, or restart the preview.

scribd