Numeric precision using colon
조회 수: 3 (최근 30일)
이전 댓글 표시
See image below. I have noticed some very interesting issues when generating a vector using the colon operator. It seems that some sort of error is introduced which isn't THAT big of a deal unless you start using that data for logic operations. Does anyone know what's going on here? The same thing occurs of you repeat the process with division instead of multiplication.

댓글 수: 0
답변 (2개)
Sebastian Castro
2015년 4월 6일
This is often associated with floating-point rounding error. The value "0.02" is not exactly represented using the "double" data type (this is the default in MATLAB).
If you redefine your time vector as follows, does this resolve what you see?
time = 2*(0:10000)/100;
- Sebastian
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!