How to round a result to 1 decimal place.
조회 수: 109 (최근 30일)
이전 댓글 표시
I have a data of 4096x64 and would like to round it to 1 decimal place. When I use DATA = round(DATA,1), the error 'Too many input arguments' appear. Is there any other way to do this?
댓글 수: 0
답변 (1개)
Adam
2017년 12월 6일
Which version of Matlab do you have?
round( data * 10 ) / 10;
is a fairly standard alternative.
댓글 수: 4
Adam
2017년 12월 6일
편집: Adam
2017년 12월 6일
Not every decimal number is precisely representable in a double (after all, there are an infinite number of floating point numbers and clearly there are not an infinite number of bit-representations to represent these).
Why do you need it to be precisely 0.3?
Note: round( 0.3333, 1 ) in later Matlab also gives an answer with a lot of trailing 0s that isn't 100% precise to 1dp.
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!