How can I display a number with only two digits after the decimal point in MATLAB?
739 次查看(过去 30 天)
显示 更早的评论
I would like to display a number with only two digits after the decimal point in MATLAB.
2 个评论
Jan
2011-3-3
What is the relation to the tag "digital signal processing"? Can you explain any details concerning the question, please?
采纳的回答
更多回答(4 个)
masoud sistaninejad
2020-12-30
format shortg
y = 3.3333333333333333333333333333333333333
y_out = round(y,2)
0 个评论
Walter Roberson
2020-12-31
For the specific case of 2 decimal places (does not work for any other number)
format bank
10/3
4 个评论
Walter Roberson
2021-9-16
x = 10/3;
sprintf('%05.2f', x)
compose("%05.2f", x)
num2str(x, '%05.2f')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!