anynan
Tests whether any element of an array is NaN.
Category: Language Fundamentals > Data Types
Syntax
tf = anynan(A)
Returns a single logical value: true if at least one element is NaN.
Description
It replaces the longer idiom any(isnan(A), 'all'). Infinite values are not NaN, so anynan([1 Inf]) is false. Integer arrays cannot hold NaN and always give false.
Input arguments
A- Numeric array of any size.
Output arguments
tf- Scalar logical.
Example
Detect NaN
anynan([1 NaN; 3 4])
anynan([1 Inf])
anynan(int8([1 2]))
Output
ans = logical
1
ans = logical
0
ans = logical
0