Extract N number of digits after the dot

8 ビュー (過去 30 日間)
neamah al-naffakh
neamah al-naffakh 2017 年 10 月 9 日
コメント済み: Star Strider 2017 年 10 月 9 日
Hi guys,
suppose N=1234.4345
I would like to store in this variable the decimal number and the first two digits only after the dot.
(e.g. N=1234.43 )
Kind Regards.

採用された回答

Star Strider
Star Strider 2017 年 10 月 9 日
You can use the most recent version of the round function, or use this emulation of it:
roundn = @(x,n) round(x .* 10.^n)./10.^n; % Round ‘x’ To ‘n’ Digits, Emulates Latest ‘round’ Function
N = 1234.4345
N = roundn(N,2)
N =
1234.4345
N =
1234.43
  2 件のコメント
neamah al-naffakh
neamah al-naffakh 2017 年 10 月 9 日
thank you so much
Star Strider
Star Strider 2017 年 10 月 9 日
As always, my pleasure.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatched Filter and Ambiguity Function についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by