ENGR 126:MATLAB for Science and Engineering Sherman Wiggin,Dom Dal Bello MATLAB Reference Sheet Original:Spring 05.Last updated:Spring20 There are many MATLAB features which cannot be included in these introductory notes.Listed below are some of the MATLAB functions and operators available,grouped by subject area.Use the on-line help facility. There are many functions beyond these.There exist,in particular,several"toolboxes"of functions for specific areas: included among such are signal processing,control systems,robust-control,system identification,optimization, splines,chemometrics,mu-analysis and synthesis,state-space identification,and neural networks.(The toolboxes, which are optional,may not be installed on your system.)These can be explored via the command help. General help help facility demo run demonstrations list variables in memory what list M-files on disk size row and column dimensions length vector length clear clear workspace computer type of computer AC local abort exit exit MATLAB quit same as exit Matrix/Array Operators Matrix Operators Array Operators addition + addition subtraction subtraction ★ multiplication multiplication right division right division left division left division power power conjugate transpose transpose Relational and Logical Operators separate subscripts and function arguments = greater than or equal execute operating system command equal not equal Special Values and ans answer when expression not assigned or eps floating point precision not pi pi i,j 8qrt(-1) Special Characters inf infinitv assignment statement NaN Not-a-Number used to form vectors and matrices clock wall clock see date date arithmetic expression precedence flops floating point operation count see( nargin number of function input arguments decimal point nargout number of function output arguments continue statement to next line Page 1 of 4
ENGR 126: MATLAB for Science and Engineering Sherman Wiggin, Dom Dal Bello MATLAB Reference Sheet Original: Spring 05. Last updated: Spring20 Page 1 of 4 There are many MATLAB features which cannot be included in these introductory notes. Listed below are some of the MATLAB functions and operators available, grouped by subject area. Use the on-line help facility. There are many functions beyond these. There exist, in particular, several "toolboxes" of functions for specific areas; included among such are signal processing, control systems, robust-control, system identification, optimization, splines, chemometrics, mu-analysis and synthesis, state-space identification, and neural networks. (The toolboxes, which are optional, may not be installed on your system.) These can be explored via the command help. General help help facility demo run demonstrations who list variables in memory what list M-files on disk size row and column dimensions length vector length clear clear workspace computer type of computer ^C local abort exit exit MATLAB quit same as exit Matrix/Array Operators Matrix Operators Array Operators + addition + addition – subtraction – subtraction * multiplication * multiplication / right division / right division \ left division \ left division ^ power ^ power ' conjugate transpose ' transpose Relational and Logical Operators greater than >= greater than or equal == equal ~= not equal & and | or ~ not Special Characters = assignment statement [ used to form vectors and matrices ] see [ ( arithmetic expression precedence ) see ( . decimal point ... continue statement to next line , separate subscripts and function arguments ; end rows, suppress printing % comments : subscripting, vector generation ! execute operating system command Special Values ans answer when expression not assigned eps floating point precision pi pi i, j sqrt(-1) inf infinity NaN Not-a-Number clock wall clock date date flops floating point operation count nargin number of function input arguments nargout number of function output arguments
ENGR 126:MATLAB for Science and Engineering Sherman Wiggin,Dom Dal Bello MATLAB Reference Sheet Original:Spring 05.Last updated:Spring20 Disk files detect empty matrices ehdir change current directory dotont strin variables delete delete file compare string variables diary diary of the session dir directory of files on disk Control Flow load conditio execute statements save save vara used end inate bif,for,while ntf file for repe ber of times ory via save while do while hreak break out of for and while loops Special Matrices return return from functions compan companion pause pause until key pressed diag diagona dentity Programming and M-files ard keyb from keyboard rd as M-file display error message hilh Hilbert tion define function invhilb inverse Hilbert eval interpret text in variables linspace linearly spaced vectors feval evaluate function given by string logspace logarithmically spaced vectors echo enable command echoing magic magic square exist check if variables exist meshdom domain for mesh points casesen ivi ones global ble startup rmonde etime elapsed time Text and Strings Matrix Manipulation abs convert string to ASCII values rot90 eval evaluate te num2str er to string flipud mat x up int2str con eger ng is a string detect string variables ape reshape hex2num convert hex string to number convert matrix to single column;A(:) Relational and I Logical Functions clc home play format indices of logical values detect ntf 4e rmatted number finite detect infinities nable command echoing Page 2 of 4
ENGR 126: MATLAB for Science and Engineering Sherman Wiggin, Dom Dal Bello MATLAB Reference Sheet Original: Spring 05. Last updated: Spring20 Page 2 of 4 Disk Files chdir change current directory delete delete file diary diary of the session dir directory of files on disk load load variables from file save save variables to file type list function or file what show M-files on disk fprintf write to a file pack compact memory via save Special Matrices compan companion diag diagonal eye identity gallery esoteric hadamard Hadamard hankel Hankel hilb Hilbert invhilb inverse Hilbert linspace linearly spaced vectors logspace logarithmically spaced vectors magic magic square meshdom domain for mesh points ones constant pascal Pascal rand random elements toeplitz Toeplitz vander Vandermonde zeros zero Matrix Manipulation rot90 rotation fliplr flip matrix left-to-right flipud flip matrix up-to-down diag diagonal matrices tril lower triangular part triu upper triangular part reshape reshape .' transpose : convert matrix to single column; A(:) Relational and Logical Functions any logical conditions all logical conditions find find array indices of logical values isnan detect NaNs finite detect infinities isempty detect empty matrices isstr detect string variables strcmp compare string variables Control Flow if conditionally execute statements elseif used with if else used with if end terminate bif, for, while for repeat statements a number of times while do while break break out of for and while loops return return from functions pause pause until key pressed Programming and M-files input get numbers from keyboard keyboard call keyboard as M-file error display error message function define function eval interpret text in variables feval evaluate function given by string echo enable command echoing exist check if variables exist casesen set case sensitivity global define global variables startup startup M-file getenv get environment string menu select item from menu etime elapsed time Text and Strings abs convert string to ASCII values eval evaluate text macro num2str convert number to string int2str convert integer to string setstr set flag indicating matrix is a string sprintf convert number to string isstr detect string variables strcomp compare string variables hex2num convert hex string to number Command Window clc clear command screen home move cursor home format set output display format disp display matrix or text fprintf print formatted number echo enable command echoing
ce and Enginenng Sherman wiggin.Dom Dal Bello Original:Spring 05.Last updated:Spring20 Graphing remainder linear X.Y plot 。1.ot3 linear 3-D plot loglog X-Y plot 1og10 log base 10 semi-log X-Y plot semilogy semi-log X.Y plot Trigonometric Functions-Angle in RADIANS polar polar plot sin sine mesh 3-dimensional mesh surface cosine contour contour plot tangent meshdom asin bar in stairs stepg atan atan2 adrant arctangent ezplot asy to ise function plotter sinh holic sine asu to t se contour plotter cosh hyperholic cosine asy to use 3D mesh tanh hyperbolie tangent ezpolar easy to use polar coordinate plotter asinh hyperbolic arcsine ezsurfe easy to use combo surface/contour acosh hyperbolic arccosine plotter atanh hyperbolic arctangent ezsurf easy to use 3-D colored surface plotter ometric Functions- Granh annotation sine Angle in DEGREES plot title xlabel x-axis label tand tangent ylabel y-axis label asind arcsine grid draw grid lines acosd arccosine text arbitrarily position text atand arctangent gtext atan2d four quadrant arctangent ginput Special Functions Granh Window Control el function manual axis scaling gamma gamma function hold hold plot on screen rat rational approximation shg show graph window erf error function clg clear graph windov inverf inverse error function subplot split graph window ellipk complete elliptic integral of first kind ellipj JJacobian elliptic integral Elementary Math Fu abs angle phase angle sqrt quare root real real part imag imaginary part coni complex conjugate round round to nearest integer Page 3 of 4
ENGR 126: MATLAB for Science and Engineering Sherman Wiggin, Dom Dal Bello MATLAB Reference Sheet Original: Spring 05. Last updated: Spring20 Page 3 of 4 Graphing plot linear X-Y plot plot3 linear 3-D plot loglog loglog X-Y plot semilogx semi-log X-Y plot semilogy semi-log X-Y plot polar polar plot mesh 3-dimensional mesh surface contour contour plot meshdom domain for mesh plots bar bar charts stairs stairstep graph errorbar add error bars ezplot easy to use function plotter ezcontour easy to use contour plotter ezmesh easy to use 3-D mesh ezpolar easy to use polar coordinate plotter ezsurfc easy to use combo surface/contour plotter ezsurf easy to use 3-D colored surface plotter Graph Annotation title plot title xlabel x-axis label ylabel y-axis label grid draw grid lines text arbitrarily position text gtext mouse-positioned text ginput graphics input Graph Window Control axis manual axis scaling hold hold plot on screen shg show graph window clg clear graph window subplot split graph window Elementary Math Functions abs absolute value or complex magnitude angle phase angle sqrt square root real real part imag imaginary part conj complex conjugate round round to nearest integer fix round toward zero floor round toward -infinity ceil round toward infinity sign signum function rem remainder exp exponential base e log natural logarithm log10 log base 10 Trigonometric Functions – Angle in RADIANS sin sine cos cosine tan tangent asin arcsine acos arccosine atan arctangent atan2 four quadrant arctangent sinh hyperbolic sine cosh hyperbolic cosine tanh hyperbolic tangent asinh hyperbolic arcsine acosh hyperbolic arccosine atanh hyperbolic arctangent Trigonometric Functions – Angle in DEGREES sind sine cosd cosine tand tangent asind arcsine acosd arccosine atand arctangent atan2d four quadrant arctangent Special Functions bessel bessel function gamma gamma function rat rational approximation erf error function inverf inverse error function ellipk complete elliptic integral of first kind ellipj Jacobian elliptic integral
orience and Engineering erence Shee Decompositions and Factorizations median median value std standard deviation tutio sort sorting -diagl to real-diag 1 chol Cholesky factorizatior eigenvalues and eigenvectors mulative sum of elements hess Hessenberg form cumprod cumulative product of elements inv diff approximate derivatives hist histograms st squares corre orth orthogonalization eonietinoomplexpair pinv nseudoinverse orthogonal-triangular decomposition Signal Processing qz QZ algorithm abs rref d row echelon form angle singular coef correlation coefficients cov covariance Matrix Conditioning deconv deconvolution cond fft radix-2 fast Fourier transform two-dim rcond condition estimate (reciprocal) rier transform fftshift FPT rearrangement Elementary Matrix Functions quad sartm matrix square root Numericalntermailyewaluateinterl funm arbitrary matrix function quadl poly characteristic polynomial adaptive Lobatto quadrature det determinant Diffe ac necker tensor product 2nd/3rd order Runge-Kutta method ode45 4th/5th order Runge-Kutta-Fehlberg Polynomials method poly characteristic polynomia roots NeaearEauatioia0anao minimum of a function of one variable mial fmins minimum of a multivariable function matrix polynomial evaluation fsolve solution of a system of nonlinear multiplication deconv division residue partial-fraction expansion fzero zero of a function of one variable polyfit polynomial curve fitting Interpolation Column-wise Data Analysis terpolation table look-ur max maximum value inte min minimum value 2-D data interpolation table look-up mean mean value interp3 3-D data interpolation table look-up Page 4 of 4
ENGR 126: MATLAB for Science and Engineering Sherman Wiggin, Dom Dal Bello MATLAB Reference Sheet Original: Spring 05. Last updated: Spring20 Page 4 of 4 Decompositions and Factorizations balance balanced form backsub backsubstitution cdf2rdf convert complex-diagl to real-diag chol Cholesky factorization eig eigenvalues and eigenvectors hess Hessenberg form inv inverse lu factors from Gaussian elimination nnls nonnegative least squares null null space orth orthogonalization pinv pseudoinverse qr orthogonal-triangular decomposition qz QZ algorithm rref reduced row echelon form schur Schur decomposition svd singular value decomposition Matrix Conditioning cond condition number in 2-norm norm 1-norm,2-norm,F-norm, infinity-norm rank rank rcond condition estimate (reciprocal) Elementary Matrix Functions expm matrix exponential logm matrix logarithm sqrtm matrix square root funm arbitrary matrix function poly characteristic polynomial det determinant trace trace kron Kronecker tensor product Polynomials poly characteristic polynomial roots polynomial roots-companion matrix roots1 polynomial roots---Laguerre's method polyval polynomial evaluation polyvalm matrix polynomial evaluation conv multiplication deconv division residue partial-fraction expansion polyfit polynomial curve fitting Column-wise Data Analysis max maximum value min minimum value mean mean value median median value std standard deviation sort sorting sum sum of elements prod product of elements cumsum cumulative sum of elements cumprod cumulative product of elements diff approximate derivatives hist histograms corrcoef correlation coefficients cov covariance matrix cplxpair reorder into complex pairs Signal Processing abs complex magnitude angle phase angle conv convolution corrcoef correlation coefficients cov covariance deconv deconvolution fft radix-2 fast Fourier transform fft2 two-dimensional FFT ifft inverse fast Fourier transform ifft2 inverse 2-D FFT fftshift FFT rearrangement Numerical Integration quad Numerically evaluate integral, adaptive Simpson quadrature quadl Numerically evaluate integral, adaptive Lobatto quadrature Differential Equation Solution ode23 2nd/3rd order Runge-Kutta method ode45 4th/5th order Runge-Kutta-Fehlberg method Nonlinear Equations and Optimization fmin minimum of a function of one variable fmins minimum of a multivariable function fsolve solution of a system of nonlinear equations (zeros of a multivariable function) fzero zero of a function of one variable Interpolation spline cubic spline interp1 1-D data interpolation table look-up interp2 2-D data interpolation table look-up interp3 3-D data interpolation table look-up