How can I display a number with only two digits after the decimal point in MATLAB?
조회 수: 1,488(최근 30일)
표시 이전 댓글
I would like to display a number with only two digits after the decimal point in MATLAB.
채택된 답변
추가 답변(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')
참고 항목
범주
Find more on Logical in Help Center and File Exchange
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!