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 CenterFile Exchange에서 Matched 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