Differences between two vectors that suppose to be equal
2 views (last 30 days)
Show older comments
Does anyone know why those are not all equal?
a=.1:.1:.9; b=[.1 .2 .3 .4 .5 .6 .7 .8 .9];
a==b
1 1 0 1 1 1 1 1 1
a(3)-b(3)
5.551115123125783e-17
0 Comments
Accepted Answer
dpb
on 12 Dec 2013
2 Comments
Matt Kindig
on 12 Dec 2013
To piggyback off this answer, try the following:
format hex
a=.1:.1:.9; b=[.1 .2 .3 .4 .5 .6 .7 .8 .9];
[a', b']
This displays the variable in hex format, which is a representation of the internal binary format that Matlab uses to store the value. Comparing across rows, you can see that the 3rd row differs in the last digit between a and b. Hence the reason a(3) ~= b(3).
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!