How can I display a number with only two digits after the decimal point in MATLAB?

739 次查看(过去 30 天)
I would like to display a number with only two digits after the decimal point in MATLAB.
  2 个评论
Jan
Jan 2011-3-3
What is the relation to the tag "digital signal processing"? Can you explain any details concerning the question, please?
Mardhika Jenned
Mardhika Jenned 2011-3-3
i'm sorry, i don't understand about tags, so i pick a random,
about the question,
i mean this
10/3 = 3.3333333333333333333333333333333333333
i just want matlab show 3.333
sorry my english is bad,
thx

请先登录,再进行评论。

采纳的回答

Jan
Jan 2011-3-3
Display a number with two digits behind the dot:
fprintf('%.2f', pi)

更多回答(4 个)

masoud sistaninejad
masoud sistaninejad 2020-12-30
format shortg
y = 3.3333333333333333333333333333333333333
y_out = round(y,2)

Mardhika Jenned
Mardhika Jenned 2011-3-3
thx

Mardhika Jenned
Mardhika Jenned 2011-3-3
example
10/3 = 3.3333
but
i want to change 3.3333 to 4.
how the formula. please tell me, thx

Walter Roberson
Walter Roberson 2020-12-31
For the specific case of 2 decimal places (does not work for any other number)
format bank
10/3
ans =
3.33
  4 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

尚未输入任何标签。

产品

Community Treasure Hunt

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

Start Hunting!

Translated by