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 to the nearest integer |
floor(x) |
Rounds down to nearest integer |
ceil(x) |
Rounds up to nearest integer |
rem(y,x) |
Remainder after dividing by (eg remainder of 17/3 is 2) |
sign(x) |
Returns -1 if ; returns 0 if ; returns 1 if . |
rand or rand(1) |
Generates a random number between 0 and 1 |
exp(x) |
Exponential function ![e^{x} e^{x}](https://lo.unisa.edu.au/filter/tex/pix.php/5cffa5d7a0c145a80dee9dc2295d5cdf.gif) |
log(x) |
Natural logarithm function, (where ) |
sqrt(x) |
Square root function, ![\sqrt{x} \sqrt{x}](https://lo.unisa.edu.au/filter/tex/pix.php/ab4785a4eafcfc553888c56a00b74e41.gif) |
abs(x) |
Absolute value function, ![\left|x\right| \left|x\right|](https://lo.unisa.edu.au/filter/tex/pix.php/0cc8bb2abd6b4e39f7b0588500cb6358.gif) |
sin(x) |
sine function ![\sin x \sin x](https://lo.unisa.edu.au/filter/tex/pix.php/7eb417c18958eb24efe56209b4f7758f.gif) |
cos(x) |
cos function ![\cos x \cos x](https://lo.unisa.edu.au/filter/tex/pix.php/9948f3609f0f4956cc0600bcaffd47c8.gif) |
tan(x) |
tan function ![\tan x \tan x](https://lo.unisa.edu.au/filter/tex/pix.php/bd5df4d326e37c5909f3b1bd16349093.gif) |