Basic Math Objective • Use Matlab to solve numeric equations. Background The usual arithmetic operations Math Operation Addition Subtraction Multiplication Division Exponentiation Parenthesis Matlab Symbol + * / ^ () Note: It is standard to only use () as parenthesis, as [] and {} are used in Matlab for Matrices and Cells, respectively Order of Operations Please Excuse My Dear Aunt Sally • P = Parenthesis • E = Exponents • M = Multiply • D = Divide • A = Add • S = Subtract Example: 1Τ -1^(1/2) is −1 2 = -1 whereas (-1)^(1/2) is −1 = i (imaginary #) 1 −1 and -1^1/2 is เต2 = −0.5000 Syntax Basic Math Operators Division Operator Examples: 6/3 = 2 6\3 = 0.5 Exponent Example: 2^3 = 8 Predefined Numbers •π • Syntax: pi • MATLAB represents pi using the floating point value closest to pi • ๐๐ฅ • Syntax: exp(x) • Factorials (i.e. 5!) • Syntax: factorial(5) Example In Matlab Built-In Functions Long Division Numeric Functions Basic Syntax ceil Rounds to the nearest integer, towards ∞ Y = ceil(X) fix Rounds to the nearest integer, towards zero Y = fix(X) floor Rounds to the nearest integer, towards -∞ Y = floor(X) round Rounds to the nearest integer Y = round(X) rem returns the remainder after division of a by b, where a is the dividend and b is the divisor r = rem(a,b) mod returns the remainder after division of a by m, where a is the dividend and m is the divisor b = mod(a,m) abs Absolute Value |x| A = abs(x) Exponents / Logs Trigonometry Refresher MATLAB Trigonometry (sin & cos) MATLAB Trigonometry (tan & cot) MATLAB Trigonometry (sec & csc) Logarithms Math: ln(5) log10(5) or log(5) log2(5) Matlab: log(5) log10(5) log2(5) Excel: LOG10(5) LOG(5,2) LN(5)