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

73 ビュー (過去 30 日間)
Milad Zarei
Milad Zarei 2017 年 2 月 13 日
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 ;-)
Neetesh Kumar Sharma
Neetesh Kumar Sharma 2022 年 9 月 15 日
its not working

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MuPAD についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by