ECE 1304 Introduction to Electrical and Computer Engineering Section 1.4 Operators and Functions 1
Commands and Operators Description clc Clears the Command Window clear Clears all variables from memory clear var1 Clears var1 from memory exist(‘name’) Determines if a file or variable exists with the name ‘name’. quit Stops MATLAB who Lists the variables currently in memory whos Lists the variables currently in memory and indicates their size and if they are complex
Commands and Operators Description + Plus; addition operator - Minus, subtraction operation * Scalar and matrix multiplication operator .* Array (point-by-point) multiplication operator ^ Scalar and matrix exponentiation operator .^ Array (point-by-point) exponentiation operator \ Left division operator / Right division operator .\ Array (point-by-point) Left division operator ./ Array (point-by-point) Right division operator : Colon; generates regularly spaced elements () Parentheses; encloses function arguments and array indices; overrides precedence
Commands and Operators Description [] Brackets; encloses array elements {} Braces; encloses cell elements . Decimal point ... Ellipsis; continues a line , Comma; separates elements in an array ; Semicolon; suppresses screen printing, denotes a new row in an array % Percent sign; designates a comment and specifies formatting ' Quote sign and transpose operator .' Nonconjugated transpose operator = Assignment operator
Special Variables and Constants Symbol Description ans Temporary variable containing the most recent answer. eps Accuracy of floating point calculations i, j Imaginary unit value; sqrt(-1) Inf Infinity NaN Not a number; occurs when an operation is undefined pi The number 3.14159…
Mathematical Functions exp(x) – Exponentiation
Mathematical Functions sqrt(x) – Square Root
Mathematical Functions log(x) – Natural Logarithm
Mathematical Functions log10(x) – Base 10 Logarithm
Mathematical Functions abs(x) – Absolute Value
Mathematical Functions angle(x) – Phase Angle
Mathematical Functions conj(x) – Complex Conjugate
Mathematical Functions imag(x) – Imaginary Part
Mathematical Functions real(x) – Real Part
Mathematical Functions ceil(x) – Round toward + Inifinity
Mathematical Functions fix(x) – Round toward Zero
Mathematical Functions floor(x) – Round toward Negative Infinity
Mathematical Functions round(x) – Round to nearest integer
Mathematical Functions sign(x) – Return algebraic sign
Trigonometric Functions All angles must be in radians angle_in_Radians = angle_in_Degrees*pi/180 cos(x) sec(x) sin(x) csc(x) tan(x) cot(x)
Inverse Trigonometric Functions All angles are returned in radians acos(x) asec(x) asin(x) acsc(x) atan(x) acot(x) atan2(y,x) Four quadrant inverse tangent. x and y are the coordinates of a point.
Trigonometric Functions All angles must be in degrees angle_in_Degrees = angle_in_Radians*180/pi cosd(x) secd(x) sind(x) cscd(x) tand(x) cotd(x)
Inverse Trigonometric Functions All angles are returned in degrees acosd(x) asecd(x) asind(x) acscd(x) atand(x) acotd(x) atan2d(y,x) Four quadrant inverse tangent. x and y are the coordinates of a point.