how can I precise number in double

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 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

製品

リリース

R2017a

質問済み:

2020 年 11 月 3 日

編集済み:

2020 年 11 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by