Possible Duplicate:
Matlab gives wrong answer
Can anyone explain to me why the following happens, when I use the 0:.1:1
-range function?
>> vecA = 0:.1:1;
>> vecB = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
>> vecA == vecB
ans =
1 1 1 0 1 1 1 1 1 1 1
Why is vecA(4) not equal to 0.3? They look quite the same ;)
vecA =
Columns 1 through 7
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000
Columns 8 through 11
0.7000 0.8000 0.9000 1.0000
>> vecB
vecB =
Columns 1 through 7
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000
Columns 8 through 11
0.7000 0.8000 0.9000 1.0000
I think there is a problem with the precision here? Or do I have a problem in my understanding?