Scalar functions in Matlab: e Matlab, Cosine function and more

These are few Basic tools you will need to know if you are just starting learning Matlab.

Scalar functions in Matlab

Before fully diving into trigonometric functions, it is necessary to state that Matlab takes as input radians while working with trigonometric function meaning and uses the symbol pi for π

e-matlab

Trigonometric sine

e-matlab

Matlab code

sin(pi)

Trigonometric cosine

e-matlab

Matlab code

cos(pi)

Trigonometric tangent

e-matlab

Matlab code

tan(3*pi/2)

Trigonometric inverse sine (arcsine)

e-matlab

Matlab code

asin(1)

Trigonometric inverse cosine (arccos)

e-matlab

Matlab code

acos(0.5)

Trigonometric inverse tangent (arctan)

e-matlab

Matlab code

atan(3/2)

e Matlab (exponential)

e-matlab

Matlab code

exp(x)

Natural logarithm

e-matlab

Matlab code

log(5/2)

Absolute value

e-matlab

Matlab code

abs(a*x+b)

Square root

e-matlab

Matlab code

sqrt(a*b)

Remainder after division

This function help you find the remainder after a division. We will use as an example the remainder of the division of 5 by 2, which is one.

Matlab code

rem(5,2)

which returns

e-matlab

Round towards nearest integer

This function will allow you to round values towards the nearest integer if you are not interested in working with decimal numbers. It is most useful while you want to round the result of an operation.

Matlab code

round(2.9)

Which returns

e-matlab

Round towards negative infinity

floor(x) rounds the elements of x to the nearest integers towards minus infinity.

Round towards positive infinity

As opposed to the floor function, ceil(x) rounds the elements of x to the nearest integers towards infinity.

Content you might like:

Write a function that find the volume of a 3D rectangle in Matlab
Scalar functions in Matlab: e Matlab, Cosine function and more
Left division vs Right Matrix division – Matlab
Convert numbers from Polar to Cartesian and vice versa

tchouken2

Related Posts