Matlab gives different results summing a few numbers with and without parentheses
4 views (last 30 days)
Show older comments
Ahmad Jamialahmadi
on 7 Nov 2013
Commented: Ahmad Jamialahmadi
on 7 Nov 2013
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
0 Comments
Accepted Answer
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!