How to use floor() In MATLAB

The floor() function is used to round the specified values towards minus infinity.

Syntax:

floor(A)

Here, floor(A) function is used to round the specified elements of A to the nearest integers less than or equal to A.

Example:

Matlab




% MATLAB code for removal of 
% decimal points using floor()
% Initializing some values
A = 2.000;
B = 1.790;
C = 0.9093;
  
% Calling the floor() function over
% the above values
floor(A)
floor(B)
floor(C)


Output:

ans =  2
ans =  1
ans = 0

How to remove decimal in MATLAB?

In this article, we are going to discuss the “Removal of decimal point” in MATLAB which can be done using sprintf(), fix(), floor(), round() and num2str() functions which are illustrated below.

Similar Reads

Using sprintf()

The sprintf() function is used to write formatted data to a string....

Using fix()

...

Using floor()

The fix() function is used to round the specified values towards zero....

Using round()

...

Using num2str( )

The floor() function is used to round the specified values towards minus infinity....

Contact Us