While using the isnan(x)
operator, I notice that the output is an array with 0
s and 1
s corresponding whether the element is NaN
or not.
The logical way to filter out NaN elements would be x(find(~isnan(x)))
, as find()
returns the indices. As a suprise to me, x(~isnan(x))
also gives the same result.
On checking, ~isnan(x)
is just an array of 1s and 0s, and for the simple case of x = rand(10,1)
, I get all(~isnan(x) == ones(10, 1))
as true. But when I run x(ones(10, 1))
, I get an array with just the first element of x
repeated 10 times, as expected.
What am I missing here?