How do I round to nearest ‘k’ decimal place in MATLAB 7.8 (R2009a)?

MATLAB's ROUND function only rounds to the nearest integer, but I want to round to the 3rd decimal place, for example.

 Accepted Answer

The ability to ROUND to the ‘k’ decimal place (for example the 3rd decimal place) is not available in MATLAB 7.8 (R2009a).
To work around this issue use this command:
x = 1.2345;
xround = round(x*1000)/1000;

More Answers (0)

Products

Release

R2009a

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!