MatrixVB Function Reference Guide -...

317
MatrixVB Function Reference Guide 4.51 release (September 2000) c Copyright MathWorks Ltd 2000

Transcript of MatrixVB Function Reference Guide -...

  • MatrixVB

    Function Reference Guide

    4.51 release (September 2000)

    c© Copyright MathWorks Ltd 2000

  • 1 Contents

    1 Contents 2

    2 Introduction 22

    3 Operators table 23

    4 Operators 24• and : Logical AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24• braces : Create or index cell arrays . . . . . . . . . . . . . . . . . . . . . . 24• brackets : Concatenate matrices . . . . . . . . . . . . . . . . . . . . . . . 25• colon : Colon operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26• ctranspose : Matrix conjugate transpose . . . . . . . . . . . . . . . . . . . 26• eq : Equal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27• ge : Greater than or equal . . . . . . . . . . . . . . . . . . . . . . . . . . . 27• gt : Greater than . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28• indexing : Access submatrices . . . . . . . . . . . . . . . . . . . . . . . . . 28• ldivide : Inverse division . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29• le : Less than or equal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30• lt : Less than . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30• mand : Logical AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30• minus : Subtraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31• mldivide : Matrix inverse division . . . . . . . . . . . . . . . . . . . . . . 31• mnot : Logical NOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32• mor : Logical OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32• mpower : Matrix power . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    5 Functions 34• abs : Absolute value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34• all : All non zero elements . . . . . . . . . . . . . . . . . . . . . . . . . . . 34• angle : Angle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35• ans : Last result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35• any : Any non zero elements . . . . . . . . . . . . . . . . . . . . . . . . . 35• automesh : Are inputs meshable . . . . . . . . . . . . . . . . . . . . . . . 36• cat : Concatenate matrices . . . . . . . . . . . . . . . . . . . . . . . . . . 36

  • • ceil : Round upward . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36• clear : Clear variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37• complex : Construct complex numbers . . . . . . . . . . . . . . . . . . . . 37• computer : Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38• conj : Conjugate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38• cplxpair : Pair complex numbers . . . . . . . . . . . . . . . . . . . . . . . 38• cross : Cross product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39• cumprod : Cumulative product . . . . . . . . . . . . . . . . . . . . . . . . 39• cumsum : Cumulative sum . . . . . . . . . . . . . . . . . . . . . . . . . . 40• delaunay : Delaunay triangulation . . . . . . . . . . . . . . . . . . . . . . 40• diff : Difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40• dot : Dot product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41• double : Convert to double . . . . . . . . . . . . . . . . . . . . . . . . . . 41• dsearch : Find nearest point . . . . . . . . . . . . . . . . . . . . . . . . . . 42• eval : Evaluate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42• exp : Exponential . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42• eye : Identity matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43• find : Find non zero elements . . . . . . . . . . . . . . . . . . . . . . . . . 43• fix : Return integer part . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44• floor : Round downward . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44• flops : Flops counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44• griddata : Fit to irregular data . . . . . . . . . . . . . . . . . . . . . . . . 45• horzcat : Horizontal concatenation . . . . . . . . . . . . . . . . . . . . . . 45• imag : Imaginary part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45• inputname : Input argument name . . . . . . . . . . . . . . . . . . . . . . 46• interp1 : 1-d interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . 46• interp2 : 2-d interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . 46• interp3 : 3-d interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . 47• kron : Kronecker product . . . . . . . . . . . . . . . . . . . . . . . . . . . 48• lasterr : Last error message . . . . . . . . . . . . . . . . . . . . . . . . . . 48• linspace : Linearly-spaced vector . . . . . . . . . . . . . . . . . . . . . . . 48• log : Natural logarithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49• log10 : base-10 logarithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 49• log2 : base-2 logarithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49• logical : Turn on logical flag . . . . . . . . . . . . . . . . . . . . . . . . . . 50• logspace : Log-spaced vector . . . . . . . . . . . . . . . . . . . . . . . . . 50• mabs : Absolute value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51• magic : Magic square . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

  • • many : Any non zero elements . . . . . . . . . . . . . . . . . . . . . . . . 51• max : Maximum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52• mcomplex : Construct complex numbers . . . . . . . . . . . . . . . . . . . 52• mdouble : Convert to double . . . . . . . . . . . . . . . . . . . . . . . . . 52• memory : Show available memory . . . . . . . . . . . . . . . . . . . . . . 53• meshdom : Mesh grid for plotting . . . . . . . . . . . . . . . . . . . . . . 53• meshgrid : Mesh grid for plotting . . . . . . . . . . . . . . . . . . . . . . . 53• mexp : Exponential . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54• mfileline : m-file line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54• mfilename : m-file name . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54• mfix : Return integer part . . . . . . . . . . . . . . . . . . . . . . . . . . . 55• min : Minimum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55• mlog : Natural logarithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 56• mlogical : Turn on logical flag . . . . . . . . . . . . . . . . . . . . . . . . . 56• mmax : Maximum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56• mmin : Minimum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57• mmod : Modulo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57• mod : Modulo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57• mrem : Reminder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58• msqrt : Square root . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58• mxor : Logical XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58• ndgrid : N-dimensional mesh grid . . . . . . . . . . . . . . . . . . . . . . . 59• nextpow2 : Next power of two . . . . . . . . . . . . . . . . . . . . . . . . 59• pow2 : Power of 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59• prod : Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60• quit : Abort program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60• real : Real part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60• reallog : Natural logarithm . . . . . . . . . . . . . . . . . . . . . . . . . . 61• realpow : Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61• realsqrt : Square root . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61• rem : Reminder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62• round : Round . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62• sign : Number sign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62• sort : Sort matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63• sortrows : Sort matrix rows . . . . . . . . . . . . . . . . . . . . . . . . . . 63• sound : Play sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63• soundM : Play sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64• soundsc : Play scaled sound . . . . . . . . . . . . . . . . . . . . . . . . . . 64

  • • spline : Interpolation by cubic spline . . . . . . . . . . . . . . . . . . . . . 64• sqrt : Square root . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65• sum : Sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65• trapz : Approximate integral . . . . . . . . . . . . . . . . . . . . . . . . . 66• tsearch : Find enclosing triangle . . . . . . . . . . . . . . . . . . . . . . . 66• uint8 : Convert to uint8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66• version : Program version . . . . . . . . . . . . . . . . . . . . . . . . . . . 67• vertcat : Vertical concatenation . . . . . . . . . . . . . . . . . . . . . . . . 67• wilkinson : Wilkinson matrix . . . . . . . . . . . . . . . . . . . . . . . . . 67• xor : Logical XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

    6 Linear algebra functions 69• axxbc : Solve sylvester equation . . . . . . . . . . . . . . . . . . . . . . . 69• balance : Pre-eigenvalues computation . . . . . . . . . . . . . . . . . . . . 69• cdf2rdf : Complex diagonal form to real diagonal form . . . . . . . . . . . 69• chol : Cholesky Factorization . . . . . . . . . . . . . . . . . . . . . . . . . 70• compan : Companion Matrix . . . . . . . . . . . . . . . . . . . . . . . . . 70• cond : Matrix condition number . . . . . . . . . . . . . . . . . . . . . . . 71• condeig : Matrix eigenvalue condition number . . . . . . . . . . . . . . . . 71• det : Determinant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71• diag : Matrix diagonal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72• eig : Eigenvalues and eigenvectors . . . . . . . . . . . . . . . . . . . . . . 72• eigv : Eigenvectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73• expm : Matrix exponential . . . . . . . . . . . . . . . . . . . . . . . . . . 73• givens : Givens plane rotation . . . . . . . . . . . . . . . . . . . . . . . . . 73• hess : Hessenbreg form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74• inv : Matrix Inverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74• logm : Matrix logarithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75• lu : LU factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75• lu L : L of LU decomposition . . . . . . . . . . . . . . . . . . . . . . . . . 76• lu U : U of LU decomposition . . . . . . . . . . . . . . . . . . . . . . . . . 76• norm : Norm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76• null : Null space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77• orth : Orthonormal basis . . . . . . . . . . . . . . . . . . . . . . . . . . . 77• pinv : Pseudo Inverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78• planerot : Plane rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . 78• qr : QR factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78• qrdelete : Update QR factorization . . . . . . . . . . . . . . . . . . . . . . 79

  • • qrinsert : Update QR factorization . . . . . . . . . . . . . . . . . . . . . . 79• qz : QZ factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80• qzval : Generalized eigenvalues . . . . . . . . . . . . . . . . . . . . . . . . 80• rank : Matrix rank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80• rcond : Estimate for the reciprocal condition number . . . . . . . . . . . . 81• rref : Reduced row echelon form . . . . . . . . . . . . . . . . . . . . . . . 81• rsf2csf : Real to complex Schur factorization . . . . . . . . . . . . . . . . . 81• schur : Schur factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . 82• schur T : T of Schur decomposition . . . . . . . . . . . . . . . . . . . . . . 82• schur U : U of Schur decomposition . . . . . . . . . . . . . . . . . . . . . 82• sqrtm : Matrix square root . . . . . . . . . . . . . . . . . . . . . . . . . . 83• subspace : Angle between subspaces . . . . . . . . . . . . . . . . . . . . . 83• svd : Singular values decomposition . . . . . . . . . . . . . . . . . . . . . 83• svd S : S of SVD decomposition . . . . . . . . . . . . . . . . . . . . . . . 84• svd U : U of SVD decomposition . . . . . . . . . . . . . . . . . . . . . . . 84• svd W : V of SVD decomposition . . . . . . . . . . . . . . . . . . . . . . . 85• trace : Matrix trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85• tril : Lower triangular matrix . . . . . . . . . . . . . . . . . . . . . . . . . 85• triu : Upper triangular matrix . . . . . . . . . . . . . . . . . . . . . . . . 86

    7 Data types 87• cell : Make cell array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87• cell2struct : Create structure from cell arrray . . . . . . . . . . . . . . . . 87• cells : Make cell array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87• class : Variable class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88• fieldnames : Structure field names . . . . . . . . . . . . . . . . . . . . . . 88• getfield : Get structure field . . . . . . . . . . . . . . . . . . . . . . . . . . 88• isa : Type of object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89• isfield : Is structure field . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89• mclass : Variable class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89• mstruct : Create structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 90• rmfield : Remove structure field . . . . . . . . . . . . . . . . . . . . . . . . 90• setfield : Set structure field . . . . . . . . . . . . . . . . . . . . . . . . . . 90• struct : Create structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91• struct2cell : Create cell from structure . . . . . . . . . . . . . . . . . . . . 91• subsasgn : Subscript assign . . . . . . . . . . . . . . . . . . . . . . . . . . 92• subsindex : Convert object to index . . . . . . . . . . . . . . . . . . . . . 92• subsref : Subscript reference . . . . . . . . . . . . . . . . . . . . . . . . . . 92

  • • which : Identify name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93• who : List of variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93• whos : Detailed list of variables . . . . . . . . . . . . . . . . . . . . . . . . 93

    8 Bit* functions 94• bitand : Bitwise AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94• bitcmp : Bitwise complement . . . . . . . . . . . . . . . . . . . . . . . . . 94• bitget : Bitwise get bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94• bitmax : Maximum representable integer . . . . . . . . . . . . . . . . . . 95• bitor : Bitwise OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95• bitreset : Bitwise reset bit . . . . . . . . . . . . . . . . . . . . . . . . . . . 95• bitset : Bitwise set bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96• bitshift : Bitwise shift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96• bitxor : Bitwise XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96• mbitand : Bitwise AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97• mbitor : Bitwise OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

    9 Control functions 98• ltifr : LTI frequency response . . . . . . . . . . . . . . . . . . . . . . . . . 98• ltitr : LTI time response . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98• ss2tf : State space to transfer function . . . . . . . . . . . . . . . . . . . . 98• ss2zp : State space to zero pole . . . . . . . . . . . . . . . . . . . . . . . . 99• tf2ss : Transfer function to state space . . . . . . . . . . . . . . . . . . . . 99• tf2zp : Transfer function zero pole . . . . . . . . . . . . . . . . . . . . . . 100• zp2ss : zero pole to state space . . . . . . . . . . . . . . . . . . . . . . . . 100• zp2tf : zero pole to transfer function . . . . . . . . . . . . . . . . . . . . . 101

    10 Set operations 102• intersect : Sets intersection . . . . . . . . . . . . . . . . . . . . . . . . . . 102• ismember : Is member in set . . . . . . . . . . . . . . . . . . . . . . . . . 102• munion : Set union . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102• setdiff : Set difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103• setxor : Set XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103• union : Set union . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103• unique : Unique elements . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

  • 11 File and text I/O functions 105• addpath : Add directory to path . . . . . . . . . . . . . . . . . . . . . . . 105• cd : Change directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105• celldisp : Display cell array . . . . . . . . . . . . . . . . . . . . . . . . . . 105• chdir : Change directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106• clc : Clear text window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106• copyfile : Copy file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106• delete : Delete file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107• deleteM : Delete file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107• dir : Show directory listing . . . . . . . . . . . . . . . . . . . . . . . . . . 107• disp : Display matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108• disp header : Display header . . . . . . . . . . . . . . . . . . . . . . . . . 108• display : Display header and matrix . . . . . . . . . . . . . . . . . . . . . 108• dos : Run DOS command . . . . . . . . . . . . . . . . . . . . . . . . . . . 109• echo : Echo program lines . . . . . . . . . . . . . . . . . . . . . . . . . . . 109• error : Abort with error . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109• exist : File existence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110• fclose : Close file handle . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110• feof : Is end of file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110• ferror : File I/O error message . . . . . . . . . . . . . . . . . . . . . . . . 111• fflush : Flush file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111• fgetl : Get line from file . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111• fgets : Get line from file . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112• filesep : File seperator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112• fopen : Open file handle . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112• format : Display format . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113• fprintf : Send formatted output to a file . . . . . . . . . . . . . . . . . . . 113• fread : Read from file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114• frewind : Move file pointer . . . . . . . . . . . . . . . . . . . . . . . . . . 115• fscanf : Get formatted input from file . . . . . . . . . . . . . . . . . . . . 115• fseek : Seek in file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115• ftell : Tell file position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116• fullfile : Filename from parts . . . . . . . . . . . . . . . . . . . . . . . . . 116• fwrite : Write to file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117• getenv : Get environment variable . . . . . . . . . . . . . . . . . . . . . . 117• help : Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118• home : Home cursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118• input : Input from keyboard . . . . . . . . . . . . . . . . . . . . . . . . . 119

  • • kbhit : Single character input . . . . . . . . . . . . . . . . . . . . . . . . . 119• load : Load variables from file . . . . . . . . . . . . . . . . . . . . . . . . . 119• ls : Show directory listing . . . . . . . . . . . . . . . . . . . . . . . . . . . 120• menu : User menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120• mkdir : Create directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120• openvar : Visual Matrix Viewer . . . . . . . . . . . . . . . . . . . . . . . . 121• path : Path to m-files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121• pathsep : Path separator . . . . . . . . . . . . . . . . . . . . . . . . . . . 121• pause : Pause program execution . . . . . . . . . . . . . . . . . . . . . . . 122• pauseM : Pause program execution . . . . . . . . . . . . . . . . . . . . . . 122• printf : Send formatted output to screen . . . . . . . . . . . . . . . . . . . 123• puts : Display string on screen . . . . . . . . . . . . . . . . . . . . . . . . 123• pwd : Get working directory . . . . . . . . . . . . . . . . . . . . . . . . . 123• rmdir : Remove directory . . . . . . . . . . . . . . . . . . . . . . . . . . . 124• rmpath : Remove directory from path . . . . . . . . . . . . . . . . . . . . 124• save : Save variables to file . . . . . . . . . . . . . . . . . . . . . . . . . . 124• stderr : Standard error file id . . . . . . . . . . . . . . . . . . . . . . . . . 125• stderrM : Standard error file id . . . . . . . . . . . . . . . . . . . . . . . . 125• stdin : Standard input file id . . . . . . . . . . . . . . . . . . . . . . . . . 125• stdinM : Standard input file id . . . . . . . . . . . . . . . . . . . . . . . . 126• stdout : Standard output file id . . . . . . . . . . . . . . . . . . . . . . . . 126• stdoutM : Standard output file id . . . . . . . . . . . . . . . . . . . . . . . 126• tempdir : Temporary directory . . . . . . . . . . . . . . . . . . . . . . . . 127• tempname : Temporary file name . . . . . . . . . . . . . . . . . . . . . . . 127• type : Type a text file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127• unix : Run Unix command . . . . . . . . . . . . . . . . . . . . . . . . . . 128• unixM : Run Unix command . . . . . . . . . . . . . . . . . . . . . . . . . 128• vbload : Load variables from file . . . . . . . . . . . . . . . . . . . . . . . 128• vbsave : Save variables to file . . . . . . . . . . . . . . . . . . . . . . . . . 129• warning : Display a warning . . . . . . . . . . . . . . . . . . . . . . . . . 129• wavread : Read wave file . . . . . . . . . . . . . . . . . . . . . . . . . . . 129• wavwrite : Write wave file . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

    12 Is* functions 131• finite : Is finite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131• is scalar : Is scalar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131• is square : Is square matrix . . . . . . . . . . . . . . . . . . . . . . . . . . 131• is struct : Is structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

  • • is vector : Is vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132• iscell : Is cell matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132• ischar : Is char matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133• iscomplex : Is matrix complex . . . . . . . . . . . . . . . . . . . . . . . . 133• isempty : Is empty matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . 133• isequal : Are arguments equal . . . . . . . . . . . . . . . . . . . . . . . . . 134• isfinite : Is finite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134• isglobal : Is global . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134• isieee : Is IEEE 754 floating-point . . . . . . . . . . . . . . . . . . . . . . 135• isinf : Is infinite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135• isletter : Is letter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135• islogical : Is logical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136• islower : Is lowercase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136• isnan : Is Not-A-Number . . . . . . . . . . . . . . . . . . . . . . . . . . . 136• isnumeric : Is matrix numeric . . . . . . . . . . . . . . . . . . . . . . . . . 137• isobject : Is object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137• isprime : Is matrix prime . . . . . . . . . . . . . . . . . . . . . . . . . . . 137• isreal : Is matrix real . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138• isspace : Is space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138• isstruct : Is structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138• isunix : Is Unix machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139• isupper : Is uppercase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139• mbint : Must be integer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139• mbintreal : Must be real integer . . . . . . . . . . . . . . . . . . . . . . . 140• mbintrealscalar : Must be real integer scalar . . . . . . . . . . . . . . . . . 140• mbintrealvector : Must be real integer vector . . . . . . . . . . . . . . . . 140• mbintscalar : Must be integer scalar . . . . . . . . . . . . . . . . . . . . . 141• mbintvector : Must be integer vector . . . . . . . . . . . . . . . . . . . . . 141• mbscalar : Must be scalar . . . . . . . . . . . . . . . . . . . . . . . . . . . 141• mbvector : Must be vector . . . . . . . . . . . . . . . . . . . . . . . . . . 142

    13 Optimization functions 143• conls : Constrained least squares . . . . . . . . . . . . . . . . . . . . . . . 143• constr : Contrained optimization . . . . . . . . . . . . . . . . . . . . . . . 143• curvefit : Curve fitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144• fmin : Find minimum of f(x) . . . . . . . . . . . . . . . . . . . . . . . . . 144• fmins : Find minimum of f(x1,x2,...) . . . . . . . . . . . . . . . . . . . . . 145• fminu : Uncontrained minimization . . . . . . . . . . . . . . . . . . . . . . 145

  • • foptions : Set options to function functions . . . . . . . . . . . . . . . . . 146• fsolve : Solve non-linear equations . . . . . . . . . . . . . . . . . . . . . . 146• fzero : Find zero of f(x) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147• leastsq : Non-linear least squares . . . . . . . . . . . . . . . . . . . . . . . 147• lp : Linear programming . . . . . . . . . . . . . . . . . . . . . . . . . . . 148• minimax : Minimax optimization . . . . . . . . . . . . . . . . . . . . . . . 148• nnls : Non-linear least squares . . . . . . . . . . . . . . . . . . . . . . . . 149• qp : Quadratic programming . . . . . . . . . . . . . . . . . . . . . . . . . 149

    14 Polynomials 150• mkpp : Make piecewise polynomial . . . . . . . . . . . . . . . . . . . . . . 150• poly : Create polynomial . . . . . . . . . . . . . . . . . . . . . . . . . . . 150• polyder : Derivative of polynomial . . . . . . . . . . . . . . . . . . . . . . 151• polyfit : Fit polynomial for data series . . . . . . . . . . . . . . . . . . . . 151• polyval : Polynomial value . . . . . . . . . . . . . . . . . . . . . . . . . . 151• polyvalm : Polynomial matrix value . . . . . . . . . . . . . . . . . . . . . 152• ppval : Evaluate piecewise polynomial . . . . . . . . . . . . . . . . . . . . 152• roots : Polynomial roots . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152• unmkpp : Evaluate piecewise polynomial . . . . . . . . . . . . . . . . . . 153

    15 Signal processing functions 154• conv : Convolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154• conv2 : 2-D Convolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154• corrcoef : Correlation Coefficients . . . . . . . . . . . . . . . . . . . . . . . 155• cov : Covariance matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155• deconv : Deonvolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155• del2 : Discrete Laplacian . . . . . . . . . . . . . . . . . . . . . . . . . . . 156• dft : Discrete Fourier transform . . . . . . . . . . . . . . . . . . . . . . . . 156• fft : Fourier transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157• fft2 : 2-Dimensional fourier transform . . . . . . . . . . . . . . . . . . . . 157• fftshift : Shift fft results . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158• filter : Digital FIR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158• filter2 : Digital 2-dimensional FIR . . . . . . . . . . . . . . . . . . . . . . 158• gradient : Gradient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159• ifft : Inverse Fourier transform . . . . . . . . . . . . . . . . . . . . . . . . 159• ifft2 : 2-Dimensional inverse Fourier transform . . . . . . . . . . . . . . . 160• ifftshift : Inverse fftshift . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160• sinc : Sinc function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

  • • unwrap : Smooth jumps . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

    16 Sparse functions 162• colmmd : Column permutation for sparsity . . . . . . . . . . . . . . . . . 162• colperm : Column permutation for sparsity . . . . . . . . . . . . . . . . . 162• full : Make matrix full . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162• issparse : Is sparse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163• nnz : Number of non zero elements . . . . . . . . . . . . . . . . . . . . . . 163• nonzeros : Non-zero elements . . . . . . . . . . . . . . . . . . . . . . . . . 163• nzmax : Allocated number of non zero elements . . . . . . . . . . . . . . . 164• sp2coo : Sparse to coordinate format . . . . . . . . . . . . . . . . . . . . . 164• spalloc : Allocate sparse matrix . . . . . . . . . . . . . . . . . . . . . . . . 164• sparse : Create sparse matrix from nonzero vectors . . . . . . . . . . . . . 165• spconvert : Create sparse matrix from columns . . . . . . . . . . . . . . . 165• speye : Sparse identity matrix . . . . . . . . . . . . . . . . . . . . . . . . . 165• spfun : Functions of non-zeros . . . . . . . . . . . . . . . . . . . . . . . . 166• spones : Sparse ones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166• sprand : Sparse random matrix . . . . . . . . . . . . . . . . . . . . . . . . 166• sprandn : Sparse random matrix . . . . . . . . . . . . . . . . . . . . . . . 167• spzeros : Sparse zeros matrix . . . . . . . . . . . . . . . . . . . . . . . . . 167

    17 Size and shape functions 168• columns : Number of columns . . . . . . . . . . . . . . . . . . . . . . . . . 168• flipdim : Flip matrix at a dimension . . . . . . . . . . . . . . . . . . . . . 168• fliplr : Flip matrix left-right . . . . . . . . . . . . . . . . . . . . . . . . . . 168• flipud : Flip matrix up-down . . . . . . . . . . . . . . . . . . . . . . . . . 169• ind2sub : Linear index to subscript . . . . . . . . . . . . . . . . . . . . . . 169• ipermute : Inverse permute of matrix dimensions . . . . . . . . . . . . . . 169• length : Length of matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . 170• ndims : Number of dimensions . . . . . . . . . . . . . . . . . . . . . . . . 170• permute : Permute matrix dimensions . . . . . . . . . . . . . . . . . . . . 170• repmat : Replicate matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . 171• reshape : Reshape matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . 171• rot90 : Rotate matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171• rows : Number of rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172• size : Matrix dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172• squeeze : Squeeze dimensions . . . . . . . . . . . . . . . . . . . . . . . . . 172• sub2ind : Subscript to linear index . . . . . . . . . . . . . . . . . . . . . . 173

  • 18 Statistical and random functions 174• erf : Error function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174• erfc : Complementary error function . . . . . . . . . . . . . . . . . . . . . 174• erfcx : Scaled complementary error function . . . . . . . . . . . . . . . . . 174• erfinv : Inverse error function . . . . . . . . . . . . . . . . . . . . . . . . . 175• mean : Average value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175• median : Median value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176• nchoosek : Combinations . . . . . . . . . . . . . . . . . . . . . . . . . . . 176• perms : Permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176• rand : Random numbers : uniform distribution . . . . . . . . . . . . . . . 177• randM : Random numbers : uniform distribution . . . . . . . . . . . . . . 177• randn : Random numbers : normal distribution . . . . . . . . . . . . . . . 178• randperm : Random permutation . . . . . . . . . . . . . . . . . . . . . . . 178• std : Standard deviation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178• stdM : Standard deviation . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

    19 Special functions 180• airy : Airy function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180• bessel : Bessel function of the first kind . . . . . . . . . . . . . . . . . . . 180• bessela : Bessel function of the first kind . . . . . . . . . . . . . . . . . . . 181• besselh : Bessel functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 181• besseli : Modified Bessel function of the first kind . . . . . . . . . . . . . . 181• besselj : Bessel function of the first kind . . . . . . . . . . . . . . . . . . . 182• besselk : Modified Bessel function of the second kind . . . . . . . . . . . . 182• bessely : Bessel function of the second kind . . . . . . . . . . . . . . . . . 183• beta : Beta function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183• betainc : Incomplete beta function . . . . . . . . . . . . . . . . . . . . . . 184• betaln : Ln beta function . . . . . . . . . . . . . . . . . . . . . . . . . . . 184• cart2pol : Cartesian to Polar . . . . . . . . . . . . . . . . . . . . . . . . . 185• cart2sph : Cartesian to spherical . . . . . . . . . . . . . . . . . . . . . . . 185• ellipj : Jacobian elliptic functions . . . . . . . . . . . . . . . . . . . . . . . 186• ellipke : Complete elliptic integrals . . . . . . . . . . . . . . . . . . . . . . 186• expint : Exponential integral . . . . . . . . . . . . . . . . . . . . . . . . . 186• factor : Factorize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187• gamma : Gamma function . . . . . . . . . . . . . . . . . . . . . . . . . . . 187• gammainc : Incomplete gamma function . . . . . . . . . . . . . . . . . . . 188• gammaln : Ln of the gamma function . . . . . . . . . . . . . . . . . . . . 188• gcd : Greatest common divisor . . . . . . . . . . . . . . . . . . . . . . . . 188

  • • lcm : Least common multiply . . . . . . . . . . . . . . . . . . . . . . . . . 189• pol2cart : Polar to Cartesian . . . . . . . . . . . . . . . . . . . . . . . . . 189• primes : Prime list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190• rat : Rational approximation . . . . . . . . . . . . . . . . . . . . . . . . . 190• sph2cart : Spherical to Cartesian . . . . . . . . . . . . . . . . . . . . . . . 190

    20 Special matrices 192• cauchy : Cauchy matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192• hadamard : Hadamard matrix . . . . . . . . . . . . . . . . . . . . . . . . 192• hankel : Hankel matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193• hilb : Hilbert matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193• invhilb : Inverse Hilbert matrix . . . . . . . . . . . . . . . . . . . . . . . . 193• ones : Ones matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194• pascal : Pascal matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194• pascalM : Pascal matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194• rosser : Rosser matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195• toeplitz : Toeplitz matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . 195• vander : Vandermonde matrix . . . . . . . . . . . . . . . . . . . . . . . . 195• zeros : Zeros matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

    21 String functions 197• base2dec : Convert number base . . . . . . . . . . . . . . . . . . . . . . . 197• bin2dec : Convert number base . . . . . . . . . . . . . . . . . . . . . . . . 197• blanks : Make blank string . . . . . . . . . . . . . . . . . . . . . . . . . . 197• cellstr : Make cell array of strings . . . . . . . . . . . . . . . . . . . . . . 198• char : Create string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198• deblank : Erase trailing blanks . . . . . . . . . . . . . . . . . . . . . . . . 198• dec2base : Convert number base . . . . . . . . . . . . . . . . . . . . . . . 199• dec2bin : Convert to binary . . . . . . . . . . . . . . . . . . . . . . . . . . 199• dec2hex : Convert to hexadecimal . . . . . . . . . . . . . . . . . . . . . . 199• findstr : Search for substring . . . . . . . . . . . . . . . . . . . . . . . . . 200• hex2dec : Convert number base . . . . . . . . . . . . . . . . . . . . . . . . 200• hex2num : Construct IEEE-754 float . . . . . . . . . . . . . . . . . . . . . 200• int2str : Convert integer to string . . . . . . . . . . . . . . . . . . . . . . . 201• iscellstr : Is cell matrix of strings . . . . . . . . . . . . . . . . . . . . . . . 201• lower : Lower case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201• mat2str : Matrix to string . . . . . . . . . . . . . . . . . . . . . . . . . . . 202• mchar : Convert to string . . . . . . . . . . . . . . . . . . . . . . . . . . . 202

  • • Mstr : Construct char* form matrix . . . . . . . . . . . . . . . . . . . . . 202• num2str : Number to string . . . . . . . . . . . . . . . . . . . . . . . . . . 203• setstr : Create string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203• sprintf : Send formatted output to variable . . . . . . . . . . . . . . . . . 203• sscanf : Get formatted input from string . . . . . . . . . . . . . . . . . . . 204• str2double : String to number . . . . . . . . . . . . . . . . . . . . . . . . . 204• str2mat : Strings to string matrix . . . . . . . . . . . . . . . . . . . . . . 205• str2num : String to number . . . . . . . . . . . . . . . . . . . . . . . . . . 205• strcat : String horizontal concatenation . . . . . . . . . . . . . . . . . . . 205• strcmp : Compare strings . . . . . . . . . . . . . . . . . . . . . . . . . . . 206• strcmpi : Compare strings insensitive . . . . . . . . . . . . . . . . . . . . . 206• strjust : Right justify a string . . . . . . . . . . . . . . . . . . . . . . . . . 206• strmatch : Match strings . . . . . . . . . . . . . . . . . . . . . . . . . . . 207• strncmp : Partial compare strings . . . . . . . . . . . . . . . . . . . . . . 207• strncmpi : Partial compare strings insensitive . . . . . . . . . . . . . . . . 207• strrep : Search and replace . . . . . . . . . . . . . . . . . . . . . . . . . . 208• strtok : Tokenize string . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208• strvcat : String vertical concatenation . . . . . . . . . . . . . . . . . . . . 208• TM : Construct matrix from char* . . . . . . . . . . . . . . . . . . . . . . 209• upper : Upper case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

    22 Trigonometric functions 210• acos : Inverse cosine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210• acosh : Inverse hyperbolic cosine . . . . . . . . . . . . . . . . . . . . . . . 210• acot : Inverse cotangent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210• acoth : Inverse hyperbolic cotangent . . . . . . . . . . . . . . . . . . . . . 211• acsc : Inverse cosecant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211• acsch : Inverse hyperbolic cosecant . . . . . . . . . . . . . . . . . . . . . . 212• asec : Inverse secant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212• asech : Inverse hyperbolic secant . . . . . . . . . . . . . . . . . . . . . . . 212• asin : Inverse sine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213• asinh : Inverse hyperbolic sine . . . . . . . . . . . . . . . . . . . . . . . . 213• atan : Inverse tangent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214• atan2 : Inverse tangent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214• atanh : Inverse hyperbolic tangent . . . . . . . . . . . . . . . . . . . . . . 214• cos : Cosine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215• cosh : Hyperbolic cosine . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215• cot : Cotangent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

  • • coth : Hyperbolic cotangent . . . . . . . . . . . . . . . . . . . . . . . . . . 216• csc : Cosecant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216• csch : Hyperbolic cosecant . . . . . . . . . . . . . . . . . . . . . . . . . . . 217• mcos : Cosine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217• msin : Sine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218• mtan : Tangent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218• sec : Secant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218• sech : Hyperbolic secant . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219• sin : Sine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219• sinh : Hyperbolic sine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219• tan : Tangent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220• tanh : Hyperbolic tangent . . . . . . . . . . . . . . . . . . . . . . . . . . . 220

    23 Time and date functions 221• clock : Time clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221• cputime : CPU time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221• date : Current date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221• datenum : Serial date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222• datevec : Decompose Serial date . . . . . . . . . . . . . . . . . . . . . . . 222• eomday : Last day of month . . . . . . . . . . . . . . . . . . . . . . . . . 222• etime : Elapsed time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223• mclock : Time clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223• now : Current time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223• tic : Start stopwatch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224• toc : Stop stopwatch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224• weekday : Weekday from serial date . . . . . . . . . . . . . . . . . . . . . 224

    24 Two-dimensional plots 225• area : Area plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225• bar : Vertical bar plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225• barh : Horizontal bar plot . . . . . . . . . . . . . . . . . . . . . . . . . . . 225• compass : Compass plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226• contour : Plot contours . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226• contourf : Filled contour plot . . . . . . . . . . . . . . . . . . . . . . . . . 227• errorbar : Plot with error bars . . . . . . . . . . . . . . . . . . . . . . . . 227• feather : Feather plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227• hist : Plot Histogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228• loglog : Log-log plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228

  • • pie : Pie chart plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229• plot : Linear plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230• plotyy : Plot with labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231• polar : Polar plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231• quiver : Quiver plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231• ribbon : Ribbon plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232• rose : Rose plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232• scatter : Scatter X-Y markers plot . . . . . . . . . . . . . . . . . . . . . . 232• semilogx : Log-linear plot . . . . . . . . . . . . . . . . . . . . . . . . . . . 233• semilogy : Linear-log plot . . . . . . . . . . . . . . . . . . . . . . . . . . . 233• spy : See sparsity structure . . . . . . . . . . . . . . . . . . . . . . . . . . 233• stairs : Stairs plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234• stem : Stem plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

    25 Three-dimensional plots 235• bar3 : 3D vertical bar plot . . . . . . . . . . . . . . . . . . . . . . . . . . 235• bar3h : 3D horizontal bar plot . . . . . . . . . . . . . . . . . . . . . . . . 235• contour3 : Plot 3-dimensional contours . . . . . . . . . . . . . . . . . . . . 235• mesh : Draw 3-dimensional mesh . . . . . . . . . . . . . . . . . . . . . . . 236• meshc : Draw mesh and contour . . . . . . . . . . . . . . . . . . . . . . . 236• pcolor : Image plot of surface levels . . . . . . . . . . . . . . . . . . . . . 237• pie3 : 3D pie chart plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237• plot3 : 3-dimensional plot . . . . . . . . . . . . . . . . . . . . . . . . . . . 237• scatter3 : 3D plot of scatter X-Y points . . . . . . . . . . . . . . . . . . . 238• surf : 3D filled surface plot . . . . . . . . . . . . . . . . . . . . . . . . . . 238• surfc : Surface plot with contour below it . . . . . . . . . . . . . . . . . . 239• surfl : 3D filled surface plot with light . . . . . . . . . . . . . . . . . . . . 239

    26 Plot customization 240• axis : Modify axis ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . 240• clf : Clear figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240• close : Close window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240• designer : Opens the GUI designer . . . . . . . . . . . . . . . . . . . . . . 241• figure : Switch or create new window . . . . . . . . . . . . . . . . . . . . . 241• grid : Toggle grid lines on axes . . . . . . . . . . . . . . . . . . . . . . . . 245• hold : Set hold state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245• legend : Add legend to plot . . . . . . . . . . . . . . . . . . . . . . . . . . 245• print : Print figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246

  • • subplot : Create several plots . . . . . . . . . . . . . . . . . . . . . . . . . 246• text : Place text on plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247• title : Add plot title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249• xlabel : Add label to the x axis . . . . . . . . . . . . . . . . . . . . . . . . 249• ylabel : Add label to the y axis . . . . . . . . . . . . . . . . . . . . . . . . 250• zlabel : Add label to the z axis . . . . . . . . . . . . . . . . . . . . . . . . 250• zoom : Zoom into plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250

    27 Color functions 251• autumn : Autumn colormap . . . . . . . . . . . . . . . . . . . . . . . . . . 251• bone : Bone colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251• brighten : Brightens the current colormap . . . . . . . . . . . . . . . . . . 251• caxis : Set color axis values for plots and images . . . . . . . . . . . . . . 252• colorbar : Display colormap values . . . . . . . . . . . . . . . . . . . . . . 252• colordef : Set figure default colors to black or white . . . . . . . . . . . . . 253• colormap : Set and get the colormap . . . . . . . . . . . . . . . . . . . . . 253• contrast : Enhance contrast of image . . . . . . . . . . . . . . . . . . . . . 253• cool : Cool colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254• copper : Copper colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . 254• flag : Flag colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254• gray : Gray colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255• grey : Grey colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255• hot : Hot colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255• hsv : HSV colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256• jet : Jet colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256• lines : Colormap of default plot line colors . . . . . . . . . . . . . . . . . . 256• pink : Pink colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257• prism : Prism colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257• rgbplot : Colormap plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257• shading : Set shading for surface plot . . . . . . . . . . . . . . . . . . . . 258• spring : Spring colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . 258• summer : Summer colormap . . . . . . . . . . . . . . . . . . . . . . . . . 258• white : White colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259• whitebg : Set figure background . . . . . . . . . . . . . . . . . . . . . . . 259• winter : Winter colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

  • 28 Imaging 261• bmpread : Read bitmap image from file . . . . . . . . . . . . . . . . . . . 261• bmpwrite : Write image to BMP file . . . . . . . . . . . . . . . . . . . . . 261• getimage : Get image from graphic object . . . . . . . . . . . . . . . . . . 261• gifread : Read image from GIF file . . . . . . . . . . . . . . . . . . . . . . 262• gifwrite : Write image to GIF file . . . . . . . . . . . . . . . . . . . . . . . 262• im2double : Convert image to double . . . . . . . . . . . . . . . . . . . . . 262• image : Display bitmap image . . . . . . . . . . . . . . . . . . . . . . . . 263• imagesc : Create scaled image object . . . . . . . . . . . . . . . . . . . . . 263• imfinfo : Image file information . . . . . . . . . . . . . . . . . . . . . . . . 264• imread : Read image and colormap from file . . . . . . . . . . . . . . . . . 264• imshow : Show true-color or indexed image . . . . . . . . . . . . . . . . . 264• imwrite : Write image and colormap to file . . . . . . . . . . . . . . . . . 265• pcxread : Read image from PCX file . . . . . . . . . . . . . . . . . . . . . 265• pcxwrite : Write image to PCX file . . . . . . . . . . . . . . . . . . . . . . 266• subimage : Prepare image in multi-images figure . . . . . . . . . . . . . . 266• tiffread : Read image from TIFF file . . . . . . . . . . . . . . . . . . . . . 266• tiffwrite : Write image to TIFF file . . . . . . . . . . . . . . . . . . . . . . 267• truesize : Rescale figure to true size . . . . . . . . . . . . . . . . . . . . . 267

    29 User-interface dialogs 268• dialog : Generic dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268• errordlg : Error dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268• helpdlg : Help dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268• helpwin : Show help window . . . . . . . . . . . . . . . . . . . . . . . . . 269• inputdlg : Input dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269• makemenu : Create user menu . . . . . . . . . . . . . . . . . . . . . . . . 270• menu : Menu dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270• msgbox : Message box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271• printdlg : Print dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271• questdlg : Question dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . 271• uigetfile : Open file dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . 272• uiputfile : Save file dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . 272• uisetcolor : Color selection dialog . . . . . . . . . . . . . . . . . . . . . . . 273• uisetfont : Font selection dialog . . . . . . . . . . . . . . . . . . . . . . . . 273• waitbar : Progress bar dialog . . . . . . . . . . . . . . . . . . . . . . . . . 273• warndlg : Warning dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . 274

  • 30 Handle graphics functions 275• allchild : Child list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275• axes : Create a axes for subsequent plots . . . . . . . . . . . . . . . . . . 275• axesposition : Axes position . . . . . . . . . . . . . . . . . . . . . . . . . . 278• box : Make box around plot . . . . . . . . . . . . . . . . . . . . . . . . . . 279• capture : Capture figure area . . . . . . . . . . . . . . . . . . . . . . . . . 279• cla : Clear axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279• clabel : Add contour heights labels . . . . . . . . . . . . . . . . . . . . . . 280• clg : Clear figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280• clruprop : Clear user property . . . . . . . . . . . . . . . . . . . . . . . . 280• consolemode : Control console window . . . . . . . . . . . . . . . . . . . . 281• datetick : Label ticks with dates . . . . . . . . . . . . . . . . . . . . . . . 281• delete : Delete graphics object . . . . . . . . . . . . . . . . . . . . . . . . 281• deleteobj : Delete graphics object . . . . . . . . . . . . . . . . . . . . . . . 282• drawnow : Force graphics update . . . . . . . . . . . . . . . . . . . . . . . 282• figure close : Close window . . . . . . . . . . . . . . . . . . . . . . . . . . 282• fill : Filled polygons with color . . . . . . . . . . . . . . . . . . . . . . . . 283• findall : Find all graphics objects . . . . . . . . . . . . . . . . . . . . . . . 283• findfigs : Find hidden figures . . . . . . . . . . . . . . . . . . . . . . . . . 283• findobj : Find graphics object . . . . . . . . . . . . . . . . . . . . . . . . . 284• gca : Get current axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284• gcbf : Get callback originating figure . . . . . . . . . . . . . . . . . . . . . 285• gcbo : Get callback originating object . . . . . . . . . . . . . . . . . . . . 285• gcf : Get current figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285• gco : Get current object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286• get : Get object property . . . . . . . . . . . . . . . . . . . . . . . . . . . 286• getframe : Capture figure area . . . . . . . . . . . . . . . . . . . . . . . . 286• getpts : Visual selection of points . . . . . . . . . . . . . . . . . . . . . . . 287• getuprop : Get user property . . . . . . . . . . . . . . . . . . . . . . . . . 287• ginput : Select axes point using mouse . . . . . . . . . . . . . . . . . . . . 287• gtext : Place text on axes using mouse . . . . . . . . . . . . . . . . . . . . 288• hwcontrol : Create a hardware/communication object . . . . . . . . . . . 288• ishandle : Check if a valid handle . . . . . . . . . . . . . . . . . . . . . . . 290• ishold : Get hold state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290• line : Create low level line plot . . . . . . . . . . . . . . . . . . . . . . . . 291• mget : Get object property . . . . . . . . . . . . . . . . . . . . . . . . . . 294• mset : Set object property . . . . . . . . . . . . . . . . . . . . . . . . . . . 294• newplot : Prepare axes for additional plot . . . . . . . . . . . . . . . . . . 294

  • • orient : Orientation of paper for printing . . . . . . . . . . . . . . . . . . . 295• patch : Create low level polygon plot . . . . . . . . . . . . . . . . . . . . . 295• peaks : Generate data for 3-D plots . . . . . . . . . . . . . . . . . . . . . 298• popupstr : Label string of menu item . . . . . . . . . . . . . . . . . . . . . 298• rectangle : Create low level rectangle object . . . . . . . . . . . . . . . . . 298• refresh : Refresh graphics on figure . . . . . . . . . . . . . . . . . . . . . . 301• reset : Reset graphics object . . . . . . . . . . . . . . . . . . . . . . . . . 302• root : Graphics root object . . . . . . . . . . . . . . . . . . . . . . . . . . 302• rotate3d : 3D rotation of plot . . . . . . . . . . . . . . . . . . . . . . . . . 303• set : Set object property . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303• setstatus : Set UI string . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303• setuprop : Set user property . . . . . . . . . . . . . . . . . . . . . . . . . 304• shg : Show graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304• surface : Create low level surface plot . . . . . . . . . . . . . . . . . . . . 304• textwrap : Wrap text to fit in object . . . . . . . . . . . . . . . . . . . . . 307• uicontextmenu : Create a context sensitive menu . . . . . . . . . . . . . . 308• uicontrol : Create a user interface object . . . . . . . . . . . . . . . . . . . 309• uimenu : Create a menu or submenu . . . . . . . . . . . . . . . . . . . . . 312• uiresume : Continue after uiwait . . . . . . . . . . . . . . . . . . . . . . . 313• uiwait : Pause until uiresume . . . . . . . . . . . . . . . . . . . . . . . . . 313• umtoggle : Toggles state of the menu item . . . . . . . . . . . . . . . . . . 314• vbaxes : VB axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314• vbrefresh : Refresh VB figure . . . . . . . . . . . . . . . . . . . . . . . . . 314• view : Change viewpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . 315• waitfor : Wait for an object to change . . . . . . . . . . . . . . . . . . . . 315• waitforbuttonpress : Wait for keyboard or mouse click . . . . . . . . . . . 315• watchoff : Set mouse pointer to arrow . . . . . . . . . . . . . . . . . . . . 316• watchon : Set mouse pointer to hourglass . . . . . . . . . . . . . . . . . . 316• winaxes : Create axes from window . . . . . . . . . . . . . . . . . . . . . . 316

  • MatrixVB Function Reference Guide 22

    2 Introduction

    This Reference Guide describes the functions available for programming using MatrixVB.

    Further documentation can be found in the User’s Guide or from our web sitehttp://www.mathworks.com/ .

    MATLAB is a registered trademark of The MathWorks, Inc. All other product names mentionedherein may be trademarks and/or registered trademarks of their respective owners.

    http://www.mathworks.com/

  • MatrixVB Function Reference Guide 23

    3 Operators table

    In the table below, all the operators are presented, along with the C++ equivalent. Documen-tation for an operator is found at the corresponding function entry.

    Operator C++ equivalent Functiona+b a+b plusa-b a-b minusa.*b times(a,b) timesa./b rdivide(a,b) rdividea.\b ldivide(a,b) ldividea/b a/b mrdivide\ mldivide(a,b) mldividea’ ctranspose(a) ctransposea.’ transpose(a) transpose

    a:b:c colon(a,b,c) colona=b gea==b a==b eqa˜=b a!=b nea—b a——b ora&b a&&b and˜a !a not

    !cmd system(cmd) system( ) ( ) parentheses

    [a b ...] (BR(a),b,...) brackets[a;b ...] (BR(a),semi,b,...) brackets

    a{b} a.br(b) braces{ } (CL(a),b,...) braces

  • MatrixVB Function Reference Guide 24

    4 Operators

    • and . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Logical ANDDescription

    z=and(x,y) returns logical x&y. z will be 1 if and only if x and y are both true (non-zero).

    Only two arguments are allowed in the and(x,y) form of the command, although the argu-ments may be vectors or arrays); more arguments are allowed if the command is written asz=x&y&...&p&q.

    When the input arguments are vectors or arrays, and returns the logical AND of correspondingelements of the arrays.

    Examples

    z=and(2,1) returns z=1 because both input arguments are true (non-zero).

    [1 0 1 0 0 1] & [1 1 0 0 1 1] returns [1 0 0 0 0 1].

    and is named mand in C++ and Visual Basic programs.

    See Also

    all,any,logical,mand,not,or,xor

    • braces . . . . . . . . . . . . . . . . . . . . . . . Create or index cell arraysDescription

    y={a b ...} creates a cell array y with a, b, ... in its cells. Cell arrays created by this syntaxcan have up to two dimensions (i.e., y={a b; c d} creates a 2x2 cell array).y=a{b}, where a is a cell array, returns the contents of the cell array a in position b. In contrast,a(b) returns a cell array, whose contents are the variable b.

    Examples

    If A is[ 1 1 0

    0 0 1

    ]and B is

    [ 1 00 1

    ], then Y={A B} produces the result,

  • MatrixVB Function Reference Guide 25

    Y (1x2)=2 cell elements real (184 bytes) =

    [2x3 double] [2x2 double]

    where Y{1} returns the array A, Y(1) returns a cell array containing the array A, Y{2} returnsthe array B, and Y(2) returns a new cell array containing the array B.

    See Also

    brackets,indexing,parentheses

    • brackets . . . . . . . . . . . . . . . . . . . . . . . . . . Concatenate matricesDescription

    [a b] returns the matrices a and b concatenated horizontally. a and b must have the samenumber of rows.

    [a;b] returns the matrices a and b concatenated vertically. a and b must have the same numberof columns.

    These rules can be chained to produce, for instance, [a b c;d e f].

    Examples

    If A is[ 1 1 0

    0 0 1

    ]and B is

    [ 1 00 1

    ], [A B] will yield

    [ 1 1 0 1 00 0 1 0 1

    ]

    See Also

    braces,cat,horzcat,parentheses,semi,vertcat

  • MatrixVB Function Reference Guide 26

    • colon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Colon operatorDescription

    y=colon(j,i,k), or y=j:i:k, returns a row vector ranging from j to k with i increments. kwill not necessarily be the last element of the vector; rather, the last element of the sequence jj+i j+2i ... will be the last element of the vector.

    Examples

    1:4:13, 1:4:14, 1:4:15 and 1:4:16 all return the vector [1 5 9 13].

    See Also

    find,indexing,linspace,logspace,ramp

    • ctranspose . . . . . . . . . . . . . . . . . Matrix conjugate transposeDescription

    y=ctranspose(x) is the matrix conjugate transpose, x’.

    Examples

    If A is[ 1 + 2i 2 + i

    2− 4i 3 + i], A’ is

    [ 1− 2i 2 + 4i2− i 3− i

    ].

    See Also

    flipdim,rot90,transpose

  • MatrixVB Function Reference Guide 27

    • eq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .EqualDescription

    z=eq(x,y) compares x and y, and returns 1 if x==y, 0 otherwise.

    If x and y are arrays of the same size, corresponding elements are compared, and the result isan array of the same size as x and y.

    Examples

    If x is[ 1 3 5

    2 4 6

    ]and y is

    [ 5 3 22 4 1

    ], x==y will return

    [ 0 1 01 1 0

    ],

    See Also

    all,any,ge,gt,isequal,le,logical,lt,ne

    • ge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Greater than or equalDescription

    z=ge(x,y) is 1 if x≥ y and 0 otherwise.

    Examples

    If x is[ 1 3 5

    2 4 6

    ]and y is

    [ 5 3 22 4 1

    ], x>=y will return

    [ 0 1 11 1 1

    ],

    See Also

    all,any,eq,gt,le,logical,lt,ne

  • MatrixVB Function Reference Guide 28

    • gt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Greater thanDescription

    z=gt(x,y) is 1 if x>y and 0 otherwise.

    Examples

    If x is[ 1 3 5

    2 4 6

    ]and y is

    [ 5 3 22 4 1

    ], x>y will return

    [ 0 0 10 0 1

    ],

    See Also

    all,any,eq,ge,le,logical,lt,ne

    • indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . Access submatricesDescription

    y=x(v) returns the elements of x specified by v.

    x(v)=y sets the elements of x specified by v to be y. If y is an empty matrix, the indexedelements are deleted from the matrix x. y must either be a scalar or an array of the same sizeas the submatrix x(v).

    Indexing can be in more than one dimension, for instance x(v,w). In this case, v specifies therows and w specifies the columns of the submatrix.

    Indices may be of three types:

    regular

    Regular index contains numbers, the indices into the indexed matrix.

    logical

    Logical matrices are arrays of 1’s and 0’s, resulting from functions that give true-false results,such as ,==,all,any. A logical index acts as a mask on the indexed matrix, so that onlythe elements of the indexed matrix which correspond to non-zero (1) elements of the mask arereturned.

  • MatrixVB Function Reference Guide 29

    colon

    Indexing with : is same as selecting the whole dimension.

    The end keyword in an indexing expression means the last index in that dimension.

    Examples

    For A=

    [ 1 2 32 3 43 4 5

    ],

    y=A(:,3) returns y=

    { 345

    }.

    If q is a logical mask, such as q=logical([1; 0; 1]), y(q) returns{ 3

    5

    }.

    See Also

    braces,colon,logical,parentheses

    • ldivide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Inverse divisionDescription

    z=ldivide(x,y) returns the result of the element-by-element division of y by x, x.\y.

    Examples[ 1 2 33 2 1

    ].\[ 4 2 3

    6 6 8

    ]=[ 4 1 1

    2 3 8

    ].

    See Also

    minus,mrdivide,plus,rdivide,times

  • MatrixVB Function Reference Guide 30

    • le . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Less than or equalDescription

    z=le(x,y) is 1 if x≤ y and 0 otherwise.

    Examples

    If x is[ 1 3 5

    2 4 6

    ]and y is

    [ 5 3 22 4 1

    ], x

  • MatrixVB Function Reference Guide 31

    See Also

    and

    • minus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .SubtractionDescription

    z=minus(x,y) returns the result of subtracting y from x, x-y.

    x-y, where x and y are arrays with the same dimensions, subtracts each element of y from thecorresponding element of x. If y is a scalar, x-y subtracts y from each element of x.

    Examples[ 1 23 4

    ]−[ 2 4

    1 2

    ]=[ −1 −2

    2 2

    ].

    [ 1 23 4

    ]− 3 =

    [ −2 −10 1

    ].

    See Also

    ldivide,plus,rdivide,times

    • mldivide . . . . . . . . . . . . . . . . . . . . . . . . .Matrix inverse divisionDescription

    z=mldivide(x,y) returns the result of matrix division of y by x, x\y. z=x\y produces thesolution z to the matrix equation xz = y. x and y must have the same number of rows; z willhave the same number of rows as x has columns, and the same number of columns as y.

    Examples

    z=A\eye(size(A)) is one means of calculating the inverse of a square matrix.

  • MatrixVB Function Reference Guide 32

    See Also

    colmmd,colperm,inv,lu,mrdivide,mtimes,qr,rem,times

    • mnot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Logical NOTDescription

    not is named mnot in C++ and Visual Basic programs.

    See Also

    not

    • mor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Logical ORDescription

    or is named mor in C++ and Visual Basic programs.

    See Also

    or

    • mpower . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Matrix powerDescription

    z=mpower(x,y), where x is a square matrix and y is a scalar, is x raised to the y-th power, xy.z=mpower(x,y), where x is a scalar and y is a matrix, is something else entirely. z=mpower(x,y),where both x and y are square matrices, is an error.

  • MatrixVB Function Reference Guide 33

    See Also

    log,power,powM

  • MatrixVB Function Reference Guide 34

    5 Functions

    • abs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Absolute valueDescription

    abs(x) is the absolute value of x, |x|. If x is complex,the return value is computed according to

    abs(x) =√

    real(x)2 + imag(x)2.

    without overflow.

    abs is named mabs in C++ and Visual Basic programs.

    See Also

    angle,conj,cplxpair,imag,mabs,polar,polyfit,real,setstr,sign

    • all . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .All non zero elementsDescription

    y=all(x) returns logical 1 if all x elements along a dimension are non-zeros, and logical 0otherwise.

    The dimension can be explicitly given as an optional argument, after all other input arguments,as in y=all(...,dimension). If it is not specified, the default dimension is 1 for row vectorsand 2 otherwise.

    See Also

    and,any,eq,ge,gt,islogical,le,logical,lt,ne,or

  • MatrixVB Function Reference Guide 35

    • angle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . AngleDescription

    y=angle(x) is the phase angle of x,

    angle(x) = atan2(imag(x), real(x)).

    If x is real, the result is 0 for non-negative x and π otherwise.

    See Also

    abs,cart2pol,cart2sph,conj,imag,pol2cart,polar,real,sph2cart,unwrap

    • ans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Last resultDescription

    ans contains the last result displayed on screen.

    See Also

    disp,echo

    • any . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Any non zero elementsDescription

    y=any(x) returns logical 1 if any of the elements along a dimension is non-zero, and logical 0otherwise.

    The dimension can be explicitly given as an optional argument, after all other input arguments,as in y=any(...,dimension). If it is not specified, the default dimension is 1 for row vectorsand 2 otherwise.

    any is named many in C++ and Visual Basic programs.

  • MatrixVB Function Reference Guide 36

    See Also

    all,and,eq,ge,gt,isequal,islogical,le,logical,lt,many,ne,or

    • automesh . . . . . . . . . . . . . . . . . . . . . . . . . Are inputs meshableDescription

    a=automesh(x,y) or a=automesh(x,y,z) returns 1 if the input variables should be auto-meshed.

    See Also

    mesh

    • cat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Concatenate matricesDescription

    z=cat(x,y,dim) returns the matrices x and y concatenated along dimension dim.

    See Also

    brackets,horzcat,repmat,rot90,size,vertcat

    • ceil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Round upwardDescription

    y=ceil(x) returns an integer such that y − 1 < x ≤ y.

  • MatrixVB Function Reference Guide 37

    See Also

    fix,floor,round

    • clear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Clear variablesDescription

    clear(’x’) clears the variable ’x’ so it does not exist anymore. In compiled programs, only xcontents are cleared, by setting x to be an empty matrix. This command takes variable numberof arguments, and should be called using CL in C++ programs.

    See Also

    exist

    • complex . . . . . . . . . . . . . . . . . . . .Construct complex numbersDescription

    z=complex(a,b) returns a+ib where i=qsrt(-1).

    complex is named mcomplex in C++ and Visual Basic programs.

    See Also

    imag,mcomplex,real

  • MatrixVB Function Reference Guide 38

    • computer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PlatformDescription

    y=computer returns the platform on which the program currently runs. This information canbe useful to access platform-specific features.

    [y,m]=computer also returns the maximal matrix size in m.

    See Also

    getenv,isieee,isunix,version

    • conj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ConjugateDescription

    y=conj(x) returns the complex conjugate of x.

    See Also

    abs,angle,cplxpair,imag,isreal,polar,real

    • cplxpair . . . . . . . . . . . . . . . . . . . . . . . . . .Pair complex numbersDescription

    y=cplxpair(x,tolerance) sorts the vector x so that all complex conjugate pairs appear first,followed by the real values. tolerance set the threshold for deciding if a number is real orcomplex. If x is a matrix, cplxpair works along its columns.

    The dimension can be explicitly given as an optional argument, after all other input arguments,as in y=cplxpair(...,dimension). If it is not specified, the default dimension is 1 for rowvectors and 2 otherwise.

  • MatrixVB Function Reference Guide 39

    See Also

    abs,conj

    • cross . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cross productDescription

    z=cross(x,y) is the cross product of the vectors x and y, defined as

    z(1) = x(2)y(3)− x(3)y(2)z(2) = x(3)y(1)− x(1)y(3)z(3) = x(1)y(2)− x(2)y(1)

    See Also

    dot,mtimes,subspace,sum

    • cumprod . . . . . . . . . . . . . . . . . . . . . . . . . . . Cumulative productDescription

    y=cumprod(x) is the cumulative product of x, computed along a dimension.

    The dimension can be explicitly given as an optional argument, after all other input arguments,as in y=cumprod(...,dimension). If it is not specified, the default dimension is 1 for rowvectors and 2 otherwise.

    See Also

    cumsum,prod

  • MatrixVB Function Reference Guide 40

    • cumsum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cumulative sumDescription

    y=cumsum(x) is the cumulative sum, computed along a dimension of the matrix x.

    The dimension can be explicitly given as an optional argument, after all other input arguments,as in y=cumsum(...,dimension). If it is not specified, the default dimension is 1 for row vectorsand 2 otherwise.

    See Also

    cumprod,diff,sum,trapz

    • delaunay . . . . . . . . . . . . . . . . . . . . . . . . Delaunay triangulationDescription

    z=delaunay(x,y) is a m by 3 matrix describing the triangle connections between the (x,y)data points, where there are m points. An optional third argument, ’sorted’, specifies that the(x,y) data points are sorted and unique. The argument causes delaunay to skip the sortingstep.

    See Also

    dsearch,griddata,tsearch

    • diff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DifferenceDescription

    z=diff(x,n) returns the difference between adjacent elements of x, computed n times. On eachiteration, x is shortened by one element along a dimension.

  • MatrixVB Function Reference Guide 41

    The dimension can be explicitly given as an optional argument, after all other input arguments,as in y=diff(...,dimension). If it is not specified, the default dimension is 1 for row vectorsand 2 otherwise.

    See Also

    cumsum,sum,unwrap

    • dot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Dot productDescription

    z=dot(x,y) is the dot product of the vectors x and y, defined as

    dot(x, y) = x′ ∗ y

    The dimension can be explicitly given as an optional argument, after all other input arguments,as in y=dot(...,dimension). If it is not specified, the default dimension is 1 for row vectorsand 2 otherwise.

    See Also

    cross,mtimes,subspace,sum

    • double . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Convert to doubleDescription

    y=double(x) returns y, with each value converted to double precision.

    double is named mdouble in C++ and Visual Basic programs.

  • MatrixVB Function Reference Guide 42

    See Also

    cell,char,full,isa,isnumeric,mdouble,mlogical,uint8

    • dsearch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Find nearest pointDescription

    n=dsearch(x,y,tri,xi,yi) returns the index n of the point (x(n),y(n)), which is nearest tothe given point (xi,yi). The parameter tri is obtained from calling delaunay.

    See Also

    delaunay,tsearch

    • eval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . EvaluateDescription

    eval(x) evaluates the command x, as if typed from the command line. This command is notavailable in compiled programs.

    See Also

    feval

    • exp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ExponentialDescription

    y=exp(x) returns the exponential of x,

    exp(x) = ex

  • MatrixVB Function Reference Guide 43

    where e=2.71828... .If x is complex,

    exp(x) = ereal(x) · (cos(imag(x) + i · sin(imag(x))))

    exp is named mexp in C++ and Visual Basic programs.

    See Also

    expm,log,log10,mexp

    • eye . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Identity matrixDescription

    y=eye(m,n) is a m-by-n identity matrix, composed of all zeros, except on the main diagonalwhere it is 1.Also, eye(n)=eye(n,n) and eye([m n])=eye(m,n).

    See Also

    ones,size,zeros

    • find . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Find non zero elementsDescription

    y=find(x) returns the linear indices of the non-zero elements in x.

    [i,j,v]=find(x) returns the row and column indices of the non-zero elements in x, in i and jrespectively, and the non-zero elements in v. The output variable v may be omitted.

    See Also

    colon,findstr,logical,nonzeros,sort,strrep,sub2ind

  • MatrixVB Function Reference Guide 44

    • fix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Return integer partDescription

    y=fix(x) returns the integer part of x.

    fix is named mfix in C++ and Visual Basic programs.

    See Also

    ceil,floor,mfix,round

    • floor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Round downwardDescription

    y=floor(x) returns an integer such that y − 1 ≤ x < y.

    See Also

    ceil,fix,round

    • flops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Flops counterDescription

    f=flops always return 0.

    See Also

    cputime

  • MatrixVB Function Reference Guide 45

    • griddata . . . . . . . . . . . . . . . . . . . . . . . . . . . Fit to irregular dataDescription

    [XI,YI,ZI]=griddata(x,y,z,xi,yi,method) interpolates the points described by (xi, yi) pairsto the surface (x, y, z). The interpolated surface is returned in (XI, Y I, ZI). If just one outputargument is given, ZI is returned. Unlike interp2, x and y need not be on a regular grid.method selects the interpolation method, out of the possible ’linear’ (default), ’nearest’ or’invdist’.

    See Also

    delaunay,interp1,interp2,interp3,spline

    • horzcat . . . . . . . . . . . . . . . . . . . . . . . .Horizontal concatenationDescription

    z=horzcat(x,y) returns the horizontal concatenation of x and y, [x y].

    See Also

    brackets,cat,repmat,rot90,str2mat,strcat,strvcat,vertcat

    • imag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Imaginary partDescription

    y=imag(x) is the imaginary part of the number x. If x is real, y=0.

    See Also

    abs,angle,conj,i,iscomplex,isreal,j,polar,real,sign

  • MatrixVB Function Reference Guide 46

    • inputname . . . . . . . . . . . . . . . . . . . . . . . Input argument nameDescription

    This command is not implemented.

    See Also

    • interp1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-d interpolationDescription

    yint=interp1(x,y,xint) returns an interpolation of xint values between (x,y) points.

    The input arguments may be followed by an optional method, which determines the interpolationmethod used.

    The methods are

    ’linear’ Linear interpolation (default).

    ’nearest’ Nearest point interpolation.

    ’spline’ Spline interpolation, same as the spline command.

    See Also

    griddata,interp2,interp3,spline

    • interp2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-d interpolationDescription

    zint=interp2(x,y,z,xint,yint) returns an interpolation of zint values between (x,y,z)triplets.

    zint=interp2(z,N) interpolates zint to be 2N times as dense as z.

  • MatrixVB Function Reference Guide 47

    The input arguments may be followed by an optional method, which determines the interpolationmethod used.

    The methods are

    ’linear’ Linear interpolation (default).

    ’nearest’ Nearest point interpolation.

    ’spline’ Spline interpolation, same as the spline command.

    See Also

    griddata,interp1,interp3,spline

    • interp3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-d interpolationDescription

    vint=interp3(x,y,z,v,xint,yint,zint) returns an interpolation of vint values between(x,y,z,w) points.

    vint=interp3(v,N) interpolates vint to be 2N times as dense as v.

    The input arguments may be followed by an optional method, which determines the interpolationmethod used.

    The methods are

    ’linear’ Linear interpolation (default).

    ’nearest’ Nearest point interpolation.

    ’spline’ Spline interpolation, same as the spline command.

    See Also

    griddata,interp1,interp2,spline

  • MatrixVB Function Reference Guide 48

    • kron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Kronecker productDescription

    z=kron(x,y) is the Kronecker product of x and y.

    See Also

    mtimes,prod

    • lasterr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Last error messageDescription

    lasterr is the last error message displayed.

    lasterr(’’) clears the last error message.

    See Also

    error

    • linspace . . . . . . . . . . . . . . . . . . . . . . . . . .Linearly-spaced vectorDescription

    z=linspace(x,y,n) returns a n-point linearly-spaced vector with values ranging from x to y.If n is omitted, 100 points are returned.

    See Also

    colon,logspace,ramp

  • MatrixVB Function Reference Guide 49

    • log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Natural logarithmDescription

    y=log(x) is the natural logarithm of x such that exp(log(x)) = x for positive x. If x is non-positive, y is complex.

    log is named mlog in C++ and Visual Basic programs.

    See Also

    exp,log10,log2,logm,mlog,mpower,power,reallog

    • log10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . base-10 logarithmDescription

    y=log10(x) is the logarithm to base 10 of x such that 10log10(x) = x for positive x. If x isnon-positive, y is complex.

    See Also

    exp,log,log2,power

    • log2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .base-2 logarithmDescription

    y=log2(x) is the logarithm to base 2 of x.

    [f,e]=log2(x) returns the fraction and exponent of the floating point number x in f and e,respectively.

  • MatrixVB Function Reference Guide 50

    See Also

    log,log10,pow2

    • logical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Turn on logical flagDescription

    y=logical(x) returns the matrix x, with the logical flag turned on. The result can be used forlogical indexing.

    logical is named mlogical in C++ and Visual Basic programs.

    See Also

    all,and,any,eq,find,ge,gt,indexing,islogical,le,lt,ne,not,or,xor

    • logspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Log-spaced vectorDescription

    z=logspace(x,y,n) returns a n-point log-spaced vector with values ranging from x to y. If n isomitted, 50 points are returned.

    If y = π, the vector range between 10x and π.

    See Also

    colon,linspace,ramp

  • MatrixVB Function Reference Guide 51

    • mabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Absolute valueDescription

    abs is named mabs in C++ and Visual Basic programs.

    See Also

    abs

    • magic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Magic squareDescription

    y=magic(n) is a magic square of order n, composed of the integers 1 : n2 with all column sumsand row sums being equal.

    See Also

    pascal,sum

    • many . . . . . . . . . . . . . . . . . . . . . . . . . . . . Any non zero elementsDescription

    any is named many in C++ and Visual Basic programs.

    See Also

    any

  • MatrixVB Function Reference Guide 52

    • max . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MaximumDescription

    z=max(x) finds the maximal element value of x along a dimension.

    The dimension can be explicitly given as an optional argument, after all other input arguments,as in y=max(...,dimension). If it is not specified, the default dimension is 1 for row vectorsand 2 otherwise.

    z=max(x,y) returns the larger value of x and y. Complex numbers are compared by theirabsolute value.

    max is named mmax in C++ and Visual Basic programs.

    See Also

    min,mmax,mmin,sort,sum

    • mcomplex . . . . . . . . . . . . . . . . . Construct complex numbersDescription

    complex is named mcomplex in C++ and Visual Basic programs.

    See Also

    complex

    • mdouble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Convert to doubleDescription

    double is named mdouble in C++ and Visual Basic programs.

  • MatrixVB Function Reference Guide 53

    See Also

    double

    • memory . . . . . . . . . . . . . . . . . . . . . . . . .Show available memoryDescription

    memory shows the available RAM.

    See Also

    • meshdom . . . . . . . . . . . . . . . . . . . . . . . . Mesh grid for plottingDescription

    [xx,yy]=meshdom(x,y) returns same xx and up-down fliped yy as meshgird does.

    See Also

    meshgrid

    • meshgrid . . . . . . . . . . . . . . . . . . . . . . . . .Mesh grid for plottingDescription

    [xx,yy]=meshgrid(x,y) returns matrices xx and yy, composed of the rows of x and the columnsof y, which can be used to plot two-dimensional functions instead of looping over x and y values.

    If y is omitted,