I've been really tripped out by this error.
Is this really expected from MATLAB or is it a bug?
Why wouldn't 0 < NaN produce an error?
According to MathWorks' documentation on NaN, the only logical operator that does not return false
with NaN
is ~=
(not equals).
This makes sense logically, though: if something is "not a number", it cannot (should not) be compared to numbers. NaN
doesn't equal anything.
Further, this is an IEEE standard: NaN
is unordered and thusly cannot be compared. It doesn't work in any IEEE 754-compliant language.
In short, it's not a bug.
NaN has special properties. Math operations performed with NaN result in a NaN (x+NaN = NaN). Comparisons to a NaN return false.
http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With