Is there a command in MATLAB that allows me to find all NaN (Not-a-Number) elements inside an array?
As noted, the best answer is isnan() (though +1 for woodchips' meta-answer). A more complete example of how to use it with logical indexing:
>> a = [1 nan;nan 2]
a =
1 NaN
NaN 2
>> %replace nan's with 0's
>> a(isnan(a))=0
a =
1 0
0 2
isnan(a) returns a logical array, an array of true & false the same size as a, with "true" every place there is a nan, which can be used to index into a.
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