Practical 1: Introduction to MATLAB

Elementary Mathematical Functions

MATLAB has a number of built-in functions, such as square root, sine, cosine, exponential, etc, functions. The following table gives a list of some commonly used functions. Later you will also write your own functions.

round(x) Rounds x to the nearest integer
floor(x) Rounds x down to nearest integer
ceil(x) Rounds x up to nearest integer
rem(y,x) Remainder after dividing y by x (eg remainder of 17/3 is 2)
sign(x) Returns -1 if x; returns 0 if x=0; returns 1 if x>0.
rand or rand(1) Generates a random number between 0 and 1
exp(x) Exponential function e^{x}
log(x) Natural logarithm function, y= \ln x (where e^{y} = x)
sqrt(x) Square root function,  \sqrt{x}
abs(x) Absolute value function, \left|x\right|
sin(x) sine function  \sin x
cos(x) cos function  \cos x
tan(x) tan function  \tan x