MATLAB: Taking the nearest decimals possible decimal Hi, I have a query i have 2 number 1] 1.6778 2] 2.032 How do i take the number 1.6778 to 1.7 ( nearest value) and 2.032 to 2.0 ? Kindly help Best Answer Y = round(X,N) where N is the number of digits to the right (when positive) or left (negative).Alternativly, y = round(X*10)/10; Related SolutionsMATLAB: Convert any decimal number between 1 to 10 by multiplying the number with 10^n. I wrote a little utility function for my own use a while back to do just that:expstr = @(x) [x*10.^floor(1-log10(abs(x))) floor(log10(abs(x)))];a = 12.345;b = expstr(a)b = 1.2345 1.0000I leave the rest to you. MATLAB: While loop until x amount correct digits Have you considered using built-in function 'round'?https://www.mathworks.com/help/matlab/ref/round.htmlThen you can just do:if round(x,3) == round(y,3) ...end Related QuestionI have an issue with the format of number when i use mean2How to tell if a value is an integerWhat does the following MATLAB code doIs precision the reason the code doesn’t workHow to calculate digits after decimal point
Best Answer