You are on page 1of 1

W.R.

Wilcox, February 2006

Comparison of common formats in mathematics, MATLAB and Excel


(Assume that in MATLAB x has been given a value and in Excel the value of x is in cell A1 and y in cellA2.)

Mathematics 3x x2
1 + 2x
2

MATLAB 3*x x^2 (1+2*x^2)/3/(4-5*x^4) or (1+2*x^2)/(3*(4-5*x^4)) log10(x) log(x) exp(x) pi cos(x)^2 cos(x^2) sqrt(x) abs(x)

Excel =3*A1 =A1^2 =(1+2*A1^2)/3/(4-5*A1^4) or =(1+2*A1^2)/(3*(4-5*A1^4)) =log(A1) =ln(A1) =exp(A1) =pi() =cos(A1)^2 =cos(A1^2) =sqrt(A1) =abs(A1) 5E+13 2E-20 Enter the following into cell A2(y): =IF(A1>1,1,-1) (Search IF in Excel help) Enter the following into cell A2(y): =IF(A1<=3,-1, IF(A1>3,IF(A1<=5,1,-1)))

3( 4 5x 4 )

log(x) ln(x) ex cos2x cos(x2)


x

|x|

5X1013 5e+13 -20 2X10 2e-20 If x > 1 set y=1, if x > 1 otherwise set y=1 y=-1. else y=1 end If 3 < x 5 set if x > 3 & x <= 5 y=1, otherwise y=1 set y=-1. else y = -1 end

Note that for trigonometric functions in MATLAB and Excel, angles must be in radians rather than degrees. To convert from degrees to radians multiply by /180.

You might also like