How to remove decimal in MATLAB? Last Updated : 29 Jul, 2021 Comments Improve Suggest changes Like Article Like Report 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. Using sprintf() The sprintf() function is used to write formatted data to a string. Syntax: sprintf(format, A) Here, sprintf(format, A) is used to format the data in A over the specified format string. Example: Matlab % MATLAB code for removal of % decimal points using sprintf() % Initializing some values A = 3.000; B = 1.420; C = 0.023; % Calling the sprintf() function over % the above values sprintf('%.f', A) sprintf('%.f', B) sprintf('%.f', C) Output: ans = 3 ans = 1 ans = 0Using fix() The fix() function is used to round the specified values towards zero. Syntax: fix(A) Here, fix(A) is used to round the specified elements of A toward zero which results in an array of integers. Example: Matlab % MATLAB code for removal % of decimal points with fix() % Initializing some values A = 3.000; B = 1.420; C = 0.023; % Calling the fix() function over % the above values fix(A) fix(B) fix(C) Output: ans = 3 ans = 1 ans = 0Using floor() 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 = 0Using round() 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. Using num2str( ) 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 Comment More infoAdvertise with us Next Article How to remove decimal in MATLAB? K Kanchan_Ray Follow Improve Article Tags : Software Engineering MATLAB-Maths MATLAB-programs Similar Reads How to reverse a number in MATLAB? In this article, we will discuss the "Reversing of a number" in MATLAB that can be done using the multiple methods which are illustrated below. Using str2num() The str2num() function is used to convert the specified character array or string to a numeric array. Syntax:  str2num(chr) Parameters: This 3 min read How to Append Data to a File in MATLAB? Appending data to a text file means adding data to a file that already exists in the storage. print() function is used to write/append data to a file in MATLAB. It writes formatted text to a file based on the format string provided to it. The format of the output/input is determined by the formattin 4 min read How to Remove Nan Values from a Matrix in MATLAB? Removal of Nan Values from a Matrix.There are multiple methods by which we can remove Nan values from a specified matrix:. Method 1: By using rmmissing( ) This function is used to remove missing entries or Nan values from a specified matrix. Syntaxrmmissing(A) Parameters: This function accepts a pa 2 min read Clear variable from Memory in MATLAB Clearing variables from memory, with the help of clearvars operation. The clearvars operation is used to clear the specified variables from memory or from the currently active workspace. Syntax:clearvars variables clearvars -except keepVariables Parameters: This function accepts a parameter. variabl 1 min read How to extract numbers from cell array in MATLAB? In this article, we are going to discuss the extraction of numbers from the cell array with the help of regexp(), str2double(), cat(), and isletter() functions. What is a Cell Array? A cell array is nothing but a data type having indexed data containers called cells, where each cell contains any typ 3 min read Normalize Data in MATLAB Data Normalization is a technique in statistical mathematics that converts the entire data into a specified range or scale or normalizes it using different methods such as by computing its z-score. There is no specific definition of normalization but, it has various meanings depending on the user's 2 min read Trigonometric Functions in MATLAB In this article, we are going to discuss trigonometric functions and their types in MATLAB. Trigonometric functions are the mathematical functions that can result in the output with the given input. There are six trigonometric functions - Sine (sin)Cosine(cos)Tangent(tan)CoTangent(cot)Secant(sec)Co 5 min read Write Data to Text Files in MATLAB Writing data to a text file means creating a file with data that will be saved on a computer's secondary memory such as a hard disk, CD-ROM, network drive, etc. fprintf() function is used to write data to a text file in MATLAB. It writes formatted text to a file exactly as specified. The different e 3 min read Text Formatting in MATLAB In the real-world data can be any form. This data may be in binary, numeric, text, array, and so on. And this data can be converted into text. In Matlab, the text can be formatted using a formatting operator along with formatting functions such as sprintf, numstr, fprintf, compose. These functions/o 4 min read Like