필터 지우기
필터 지우기

How can I reduce the number of digits after the decimal point?

조회 수: 29 (최근 30일)
Milad Zarei
Milad Zarei 2017년 2월 13일
댓글: Neetesh Kumar Sharma 2022년 9월 15일
Matlab shows a number with 2 digits after the decimal point (e.g. 0.8100) in the Command Window, but when you open the variable it is 0.810000000000000. Do you know how I can cut those zeros off?
I do not want to show them in the Command Window (print, fprint or anything like that). I want to see just 2 digits after the decimal point when I open the variable in the Variables section.
Also, I have tried round(x*1000)/1000 and Format (short and bank), and they do not do what I want to!
I saw that someone else had the same problem a while ago ( here) but no one knew the correct answer!
Thanks.

채택된 답변

Stephen23
Stephen23 2017년 2월 13일
편집: Stephen23 2017년 2월 13일
To control how numbers are displayed in the Variable Viewer, you can set the format in the Preferences:
Home tab, in the Environment section, click Preferences. Select MATLAB > Variables.
  댓글 수: 11
Walter Roberson
Walter Roberson 2017년 2월 14일
Stephen answered the question you asked, so vote for that ;-)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MuPAD에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by