How do you get a specific decimal accuracy with the fprintf function?
조회 수: 13 (최근 30일)
이전 댓글 표시
I want to display my r variable with 6 decimals, but I am not sure how to format the line. I could not really find how to with the documentation page and would appreciate some guidance, Thank you so much!!
fprintf("The estimated principle stress val is %6f .\n " + r )
채택된 답변
the cyclist
2021년 4월 20일
편집: the cyclist
2021년 4월 20일
Your r variable needs to be a second argument (not using a plus sign as you did).
r = pi;
fprintf("The estimated principle stress val is %9.6f.\n ",r)
The %9.6f indicates that the output should use 6 decimal places, and field width of 9.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Stress and Strain에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!