How to use num2str( ) In MATLAB

The num2str() function is used to convert the specified numbers to a character array.

Syntax: num2str(num)

Parameters: This function accepts a parameter.

  • num: This is the specified number.

Example:

Matlab




% MATLAB code for  removal of
% decimal points without rounding
% Initializing some values
  
num2str(3.1455567, '%.0f')


Output:

ans = 3


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....