how can I precise number in double

1 次查看(过去 30 天)
Hello,
I want to ask you how I can precise the numbers after comma
for example:
x=0.2584
the result should be x=0.2
Please help me!

采纳的回答

Ameer Hamza
Ameer Hamza 2020-11-3
编辑:Ameer Hamza 2020-11-3
If the numbers are positive
x = 0.2584
y = floor(x*10)/10
If both positive and negative 'x' are possible
y = sign(x)*floor(abs(x)*10)/10

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by