필터 지우기
필터 지우기

Truncating a number without rounding

조회 수: 101 (최근 30일)
wesso Dadoyan
wesso Dadoyan 2015년 8월 18일
댓글: Walter Roberson 2015년 8월 18일
Is it possible to truncate a number in matlab without rounding it to the first decimal point? for example, 5.17 I want it to be 5.1 and not 5.2 Thanks

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 8월 18일
  댓글 수: 1
Walter Roberson
Walter Roberson 2015년 8월 18일
For negative values you need to figure out whether you want -5.17 to go to -5.1 or to -5.2 . If you want the truncation to be "at most" the original value, then you would use floor(a*10)/10 . If you want the truncation to be "closer to 0" then you would use fix() like Azzi shows.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by