How can I display a number with only two digits after the decimal point in MATLAB?
古いコメントを表示
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?
Mardhika Jenned
2011 年 3 月 3 日
採用された回答
その他の回答 (4 件)
masoud sistaninejad
2020 年 12 月 30 日
4 投票
format shortg
y = 3.3333333333333333333333333333333333333
y_out = round(y,2)
For the specific case of 2 decimal places (does not work for any other number)
format bank
10/3
4 件のコメント
Omar Lakkis
2021 年 9 月 15 日
Thanks. I'm teaching a financial computing course and was looking for banker's output :-)
Walter Roberson
2021 年 9 月 15 日
Be careful about rounding vs truncation. I do not know what is standard for banking purposes.
Megha
2021 年 9 月 16 日
in the same scenario, could you please tell how to obtain 03.33??
x = 10/3;
sprintf('%05.2f', x)
compose("%05.2f", x)
num2str(x, '%05.2f')
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!