Matlab accuracy (when 1-1~=0)
1 view (last 30 days)
Show older comments
Damian Maxwell on 20 Sep 2022
Commented: Damian Maxwell on 21 Sep 2022
Below please find a screenshot from a sample script that really puzzles me.
When defining simple variables and then substracting them there appear to be tiny error (3e-18) that comes in with surprising results.
It would be great if somebody could explain why this happens and how to avoid it.
Eric Delgado on 20 Sep 2022
Edited: Eric Delgado on 20 Sep 2022
It's float operation universe. :)
w == (b+2*i)
abs(w - (b+2*i)) <= 1e-5 % You could use 1e-17 and still will receive a true logical value
Find more on Logical 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!