> Financial Mathematics
>> MATLAB Programming
>>> MATLAB Functions

MATLAB Functions

List of some commonly used built-in Mathematical functions in MATLAB and their examples.

Square rootsqrt(x)

Examples
(1)
>> sqrt(4) (press Enter)
ans =
     2

(2)
>> sqrt(9) (press Enter)
ans =
     3

(3)
>> sqrt(70+11) (press Enter)
ans =
     9


Exponentialexp(x)

Examples
(1)
>> exp(4) (press Enter)
ans =
     2

(2)
>> sqrt(9) (press Enter)
ans =
     3

(3)
>> sqrt(70+11) (press Enter)
ans =
     9


Log (base e)log(x)

Examples
(1)
>> log(1) (press Enter)
ans =
     0

(2)
>> log(5) (press Enter)
ans =
     1.609

(3)
>> log(1000) (press Enter)
ans =
     3.0000


Log (base 10)log10(x)

Examples
(1)
>> log10(1) (press Enter)
ans =
     0

(2)
>> log10(10) (press Enter)
ans =
     1.0000

(3)
>> log10(100) (press Enter)
ans =
     2.0000


Nth rootnthroot(x,n)

Examples
(1)
>> nthroot(25,2) (press Enter)
ans =
     5

(2)
>> nthroot(8,3) (press Enter)
ans =
     2

(3)
>> nthroot(16,4) (press Enter)
ans =
     2


Absolute Valueabs(x)

Examples
(1)
>> abs(-10) (press Enter)
ans =
     10

(2)
>> abs(-13) (press Enter)
ans =
     13


Factorialfactorial(x)

Examples
(1)
>> factorial(4) (press Enter)
ans =
     24

(2)
>> factorial(5) (press Enter)
ans =
     120


Remainderrem(x,y)

Examples
(1)
>> rem(10,3) (press Enter)
ans =
     1
[When 10 is divided by 3, the remainder is 1.]

(2)
>> rem(12,5) (press Enter)
ans =
     2
[When 12 is divided by 5, the remainder is 2.]


Trigonometric Functionssin(radian)sind(degree)

Examples
(1)
>> sin(pi/6) (press Enter)
ans =
     0.5000

(2)
>> sind(30) (press Enter)
ans =
     0.5000

(3)
>> tand(30) (press Enter)
ans =
     0.5774

(4)
>> cos(pi/4) (press Enter)
ans =
     0.7071
NOTE: Only sin(angle) for angles in radians, and sind(angle) for angles in degree. Same for all trigonometric functions: sin, cos, tan, cot, sec and cosec.

Next: MATLAB Arrays