MATLAB Information and Formulas OPERATOR PRECEDENCE 1 2 %f Fixed-Point Notation %e Exponential Notation ./ / Right Division, Matrix Right Division, %s String Characters .\ \ Left Division, %c Single Character .^ ^ Power, ~ Matrix Power Logical Negation .* * Multiplication, 5 6 Matrix Multiplication, Matrix Left Division of + Addition \t Horizontal Tab -­‐ Subtraction \n New Line : Colon Operator %% Percent Character Less Than, < <= To, 7 Integer %d .’ ‘ Transpose, Matrix Transpose, 3 4 fprintf SPECIFIER Parentheses () Less Than Or Equal \’ Single Quote Mark ’ > >= Greater Than, Greater Than Or Equal To, == ~= Equal To, Not Equal To 8 & Element-wise AND 9 | Element-wise OR 1 0 && Short-circuit AND 1 1 || Short-circuit OR COLOR SPECIFIER \\ Backslash \b Backspace Fixed-­‐Point Notation Syntax %<field_width>.<precision>f LINE STYLE SPECIFIER MARKER TYPE SPECIFIER r Red -­‐ Solid Line + g Green -­‐-­‐ Dashed Line b Blue : Dotted Line c Cyan -­‐. Dash-dot Line m Magenta y Yellow k Black w White o * . x s d ^ v > < ENG1060 Computing for Engineers Plus Sign Circle Asterisk Point Cross Square Diamond Triangle (Up) Triangle (Down) Triangle (Right) Triangle (Left) Page 1 of 3 Root Finding Bisection Method False Position Method xl + xu 2 xr = xr = xu − f ( xu )( xl − xu ) f ( xl ) − f ( xu ) Newton-­‐Raphson Method f ( xi ) xi +1 = xi − f ' ( xi ) Secant Method f ( xi )( xi −1 − xi ) xi +1 = xi − f ( xi −1 ) − f ( xi ) Modified Secant Method δxi f ( xi ) xi +1 = xi − f ( xi + δxi ) − f ( xi ) Alternative Modified Secant Method δ f (xi ) xi+1 = xi − f (xi + δ ) − f (xi ) Curve Fitting Linear Regression: Coefficient of Determination y = ao + a1 x a1 = n∑ xi yi − ∑ xi ∑ yi r2 = 2 n∑ xi2 − (∑ xi ) St − S r St Linearizing Nonlinear Models a0 = y − a1 x Standard Deviation n S t = ∑ ( yi − y ) 2 Standard Error of the Regression Estimate n 2 S r = ∑ ( y i − a 0 − a1 xi ) i =1 Nonlinear Linearized y = α1e β1x ln y = lnα1 + β1x y = α 2 x β2 log y = logα2 + β2 log x y = α3 i =1 St sy = n −1 sy / x = Sr n−2 x β3 + x 1 1 β3 1 = + y α3 α3 x Page 2 of 3 Numerical Integration (n is the number of points) Trapezoidal Rule: I = (b − a ) f (b) + f (a ) 2 1 3 Et = − f ʹ′ʹ′(ξ )(b − a ) 12 Composite Trapezoidal Rule I= n −1 h ⎡ ⎤ ( ) f x + 2 f (xi ) + f (xn )⎥ ∑ 1 ⎢ 2 ⎣ i=2 ⎦ where h= (b − a) n −1 Composite Trapezoidal Rule with Unequal Segments I = (x2 − x1 ) f (x3 ) + f (x2 ) f (xn−1 ) + f (xn ) f (x2 ) + f (x1 ) + (x3 − x2 ) + ! + (xn − xn−1 ) 2 2 2 Simpson’s 1/3 Rule h I = [ f (x1 ) + 4 f (x2 ) + f (x3 )] 3 1 5 Et = − f ( 4) (ξ )(b − a ) 2880 Simpson’s 3/8 Rule 3h [ f (x1 ) + 3 f (x2 ) + 3 f (x3 ) + f (x4 )] 8 1 Et = − f ( 4) (ξ )(b − a)5 6480 I = ⎡ ⎤ n −1 n−2 h ⎢ ⎥ Composite Simpson’s 1/3 Rule: I = ⎢ f (x1 ) + 4 ∑ f (xi ) + 2 ∑ f (x j ) + f (xn )⎥ 3 i = 2 , 4 , 6 ,... j =3, 5, 7 ,... ⎢⎣ ⎥⎦ i , even j , odd ODE: Initial Value Problems Euler’s Method yi +1 = yi + f (t i , yi )h 0 i +1 y Heun’s Method = yi + f (ti , yi )h Midpoint Method h yi +1/ 2 = yi + f (ti , yi ) 2 h t i +1 / 2 = t i + 2 yi +1 = yi + f (ti +1/ 2 , yi +1/ 2 )h f (ti , yi ) + f (ti +1 , yi0+1 ) yi +1 = yi + h 2 Page 3 of 3