How to use round() In MATLAB
The round() function is used to round the specified values to their nearest integer.
Syntax:
round(X)
Here, round(X) function is used to round the specified elements of X to their nearest integers.
Example1:
Matlab
% MATLAB code for removal of % decimal points using round() % Initializing some values A = 2.300; B = 1.790; C = 0.9093; D = 0.093; % Calling the round() function over % the above values round(A) round(B) round(C) round(D) |
Output:
ans = 2 ans = 2 ans = 1 ans = 0
Now we see how to remove decimal places without rounding. For this, we can use num2str, which converts numbers to a character array.
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.