How to tell when you have a precision problem, an equality problem, or a MATLAB bug
1 view (last 30 days)
Show older comments
I am using an educational version of MATLAB R2012a on a Mac running OS X 10.8.5.
I am having issues with equality of two different numbers. When I expand the displayed precision the numbers are exactly the same, so why is my equality failing?
EDU>> deltaArray(3,2)
ans =
0.0951
EDU>> deltaArray(3,2) == d_t
ans =
0
EDU>> d_t
d_t =
0.0951
EDU>> format 'long'
EDU>> d_t
d_t =
0.095145024596147
EDU>> deltaArray(3,2)
ans =
0.095145024596147
0 Comments
Accepted Answer
Walter Roberson
on 17 Jan 2014
format long still does not show all of the digits. Try
sprintf('%.30g - %.30g = %.30g', deltaArray(3,2), d_t, deltaArray(3,2) - d_t)
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!