Technical Solutions
Why does COLON return a vector that does not seem to be correct?
Date Last Modified: Friday, June 26, 2009
| Solution ID: | 1-536MAS | |
| Product: | MATLAB | |
| Reported in Release: | No Release | |
| Platform: | All Platforms | |
| Operating System: | All OS |
Subject:
Why does COLON return a vector that does not seem to be correct?
Problem Description:
When I create a vector using the COLON operator or the LINSPACE function, and then compare one of the elements to a variable with the same value, they are not equal. For example:
a = 0:0.1:1;
a(4)==0.3
ans =
0
Solution:This behavior is related to floating-point arithmetic and the way numbers are represented in a computer. For more information on this subject, see the related Solution below. |
Related Solutions:
|
|
Store

