필터 지우기
필터 지우기

Problems with decimal places?

조회 수: 2 (최근 30일)
Trevor Zane Simko
Trevor Zane Simko 2015년 5월 6일
댓글: Trevor Zane Simko 2015년 5월 6일
I'm writing a script that prints a certain percentage to the screen:
fprintf('Probabilty of something happeneing: %d %% \n \n',Percentage_A);
When Percentage_A (which is calculated earlier in the script) has a decimal place, such as: 92.3077, it show's up as 9.230769e+01. How do I fix this? Thank you.

채택된 답변

Walter Roberson
Walter Roberson 2015년 5월 6일
%d is only for integral numbers. If you want to print out floating point numbers without any decimal places then you can use %.0f . Or you can round() the numbers and continue to use %d

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by