Logic operation with NaN cell
lhzeng
Hello,
I have some troubles to find if a cell is blank or not.
For example,
I create a wave0, single element, which is blank.
print wave0[0]
The result is NaN.
print wave0[0]==NaN
But the result is 0, which means the statement is wrong.
Hi,
Use Numtype
numtype(num )
The numtype function returns a number which indicates what kind of value num contains.
Details
If num is a real number, numtype returns a real number whose value is:
0: num contains a normal number.
1: num contains +/-INF.
2: num contains NaN.
If num is a complex number, numtype returns a complex number in which the real part is the number type of the real part of num and the imaginary part is the number type of the imaginary part of num .
Andy
October 26, 2019 at 08:11 am - Permalink
In reply to Hi, Use Numtype numtype… by hegedus
Thanks Andy! It works
October 26, 2019 at 08:34 am - Permalink
Just a note: this is how NaN works by IEEE 488 standard. All comparisions with NaN return false. This apparently nonsensical behavior leads to a common test for NaN:
Variable a = NaN
if (a != a)
print "It's a NaN"
endif
end
October 28, 2019 at 12:10 pm - Permalink