Matlab gives different results summing a few numbers with and without parentheses
Show older comments
I was trying to find discrete integrate of a function using trapz but I kept gettin NaN for results. Searching for the issue I found out that the last point exceeds the fcuntion's range. In my case the last point should be exactly 10.424 but as you can see below Matlab gives different results by just adding or removing parentheses. Can anybody tell if something is wrong with my Matlab ??? How can I avoid that 1e-15 at the end ??
R=10.644;
A=0.507;
B=0.22;
R - A + A - B
ans =
10.423999999999999
R - A + (A - B)
ans =
10.424000000000001
Accepted Answer
More Answers (0)
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!