You are on page 1of 13

INTRODUCTION TO MATLAB

MATLAB stands for Matrix Laboratory MATLAB had many functions and toolboxes to help in various applications MATLAB is very extendable. There are many add-ons (toolboxes) for specific requirements. It allows to solve many technical computing problems, especially those with matrix and vector formulas.

DESKTOP TOOLS
Command Window -type commands Workspace -view program variables -clear to clear -double click on a variable to see it in the array editor Command History -view past commands -save a whole session using dairy Launch Pad -access tools, demos and documentation

MATLAB HELP
Can browse or search product help for a specific function or topic MATLAB help has introductory help material, basic overviews of how to use functions, plot program in MATLAB, example code, etc. lookfor keyword command also find functions that have the keyword with them doc fuction_name brings up the full documentation for the function

MATLAB OPERATORS
Arithmetic operators Relational operators Logical operators Special characters Bitwise operators Set operators

ARITHMETIC OPERATORS
Plus Minus Matrix multiply Matrix power Backslash or left matrix divide Slash or right matrix divide Element-by-element multiplication Element-by-element division Left array divide Right array divide Element-by-element power + * ^ \ / .* .\ ./ .^

RELATIONAL OPERATORS
Equal Not equal Less than Greater than Less than or equal Greater than or equal == ~= < > <= >=

LOGICAL OPERATORS
Short-circuit logical AND Short-circuit logical OR Element-wise logical AND Element-wise logical OR Logical NOT Logical EXCLUSIVE OR True if any element of vector is nonzero True if all elements of vector are nonzero && || & | ~ xor any all

SPECIAL CHARACTERS
Colon Parentheses and subscripting Brackets Braces and subscripting Decimal point Structure field access Continuation Separator Semicolon Comment Invoke operating system command Assignment Quote Transpose Complex conjugate transpose Horizontal concatenation Vertical concatenation : () [] {} . . ... , ; % ! = ' . ' [,] [;]

MATLAB FUNCTIONS
diag sum mean max min median cov std var sort det inv dot cross linspace logspace Diagonal matrices and diagonals of a matrix Sum of elements Average or mean value Largest component Smallest component Median value Covariance matrix Standard deviation Variance Sort in ascending or descending order Determinant Matrix inverse Vector dot product Vector cross product Linearly spaced vector Logarithmically spaced vector

CONTROL FUNCTIONS
Condition Control If, else, elseif Switch, case Loop Control For, while, continue, break Error Control Try, catch Program Termination return

ELEMENTARY FUNCTION
sin Sine asin, sind Cosine acos, cosd Square root sqrtm Absolute value sign, angle, unwrap Exponential expm1, log, log10, expm, exprint Common (base 10) logarithm log, log2, exp, logm Round towards nearest integer floor, ceil, fix

cos
sqrt

abs
exp

log10
round

MATLAB GRAPHICS FUNCTION


plot stem grid xlabel ylabel title subplot figure pause legend mesh axis hist bar linear plot discrete plot add grid lines X-axis label Y-axis label graph title divide figure window create new figure window wait for user response display legend 3-D mesh surface axis scaling and appearance histogram bar graph

GENERATING VECTORS FROM FUNCTIONS


zeros(m,n) ones(m,n) eye(m,n) rand(m,n) randn(m,n) magic(m) matrix with all zeros matrix with all ones the identity matrix uniformly distributed random numbers normally distributed random numbers square matrix whose elements have the same sum, along the row, column and diagonal pascal matrix

pascal(m)

You might also like