How can I display a number with only two digits after the decimal point in MATLAB?
696 views (last 30 days)
Show older comments
I would like to display a number with only two digits after the decimal point in MATLAB.
2 Comments
Jan
on 3 Mar 2011
What is the relation to the tag "digital signal processing"? Can you explain any details concerning the question, please?
Accepted Answer
More Answers (4)
masoud sistaninejad
on 30 Dec 2020
format shortg
y = 3.3333333333333333333333333333333333333
y_out = round(y,2)
0 Comments
Walter Roberson
on 31 Dec 2020
For the specific case of 2 decimal places (does not work for any other number)
format bank
10/3
4 Comments
Walter Roberson
on 16 Sep 2021
x = 10/3;
sprintf('%05.2f', x)
compose("%05.2f", x)
num2str(x, '%05.2f')
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!