Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.2 - English

Change language to:
Français - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilab Help >> Elementary Functions > Floating point > isnan

isnan

check for "Not a Number" entries

Syntax

r=isnan(x)

Arguments

x

real or complex vector or matrix r : boolean vector or matrix

Description

isnan(x) returns a boolean vector or matrix which contains true entries corresponding with "Not a Number" x entries and false entries corresponding with regular x entries.

In this paragraph, we give the reason of the existence of this function. Consider the floating point number x and assume that we want to know if this number is a Not A Number. The condition (x==%nan) is false if x is equal to %nan. This is why the function isnan is helpful: it allows to see if a floating point number is a NaN, without actually comparing its value against %nan.

Examples

isnan([1 0.01 -%nan %inf-%inf])

In the following example, we see that %nan has very particular comparison properties and compare the result with the isnan function.

%nan == %nan
%nan <> %nan
isnan(%nan)

In the following example, we extract the non-NaNs values y from the array x.

x = [1 2 %nan 3 %nan 4]
k = find(~isnan(x))
y = x(k)

See also

  • isinf — tests for infinite elements
Report an issue
<< isinf Floating point nearfloat >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Feb 14 14:57:12 CET 2019