Rounding fractions to 5 digit precision..!
11 views (last 30 days)
Show older comments
Why can't I use round(x,n)...! while using it in command window, it always gives an error " Too many input arguments".
Matlab documentation has provided a help page using the same function but that doesn't work surprisingly.....I don't understand why?
Please help !! why the above round function is not working as it should be..!
0 Comments
Answers (2)
Walter Roberson
on 2 Apr 2013
MuPAD is the symbolic math toolbox, which represents numbers differently than basic MATLAB does.
Basic MATLAB cannot round to a specific number of decimal digits because MATLAB uses binary representations of fractions, and binary cannot accurate represent decimal digits.
0.1 decimal is 0.0,0011,0011,0011,... (infinitely repeating) in binary. This has exactly the same mathematical basis for the reason why 1/7 is 0.142857,142857,142857,1428571,... (infinitely repeating) in decimal. No matter what fixed (finite) numeric base you use, base 2, base 3, base 10, base 144, whatever, you will end up with values that require an infinite repeated fraction to represent.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!