Documentation

NaN

Create array of allNaN

Description

x = nan返回“非数字”的标量表示。运营返回NaNwhen they have undefined numeric results, such as0/0或者0*Inf

example

x = nan(n)返回n-经过-nmatrix ofNaN值。

example

x = nan(SZ1,...,SZN)返回sz1-经过-。..-by-szN大批ofNaN值, whereSZ1,...,SZNindicate the size of each dimension. For example,南(3,4)returns a 3-by-4 matrix.

example

x = nan(sz)返回一系列NaN值, where the size vectorszdefinessize(X)。For example,南([3 4])returns a 3-by-4 matrix.

example

x = nan(___,打字)返回一系列NaN数据类型的值打字,这可以是'single'或者'double'

example

x = nan(___,'喜欢',p)返回一系列NaN值of the same data type, sparsity, and complexity (real or complex) asp。You can specify打字或者'like'但不是两者。

Examples

collapse all

创建一个3 x-3的矩阵NaN值。

x = nan(3)
X =3×3NaN NaN NaN NaN NaN NaN NaN NaN NaN

创建一个2 x-3 x-4的阵列NaN值并显示其大小。

x = nan(2,3,4); size(X)
ans =1×32 3 4

Create an array ofNaN值that is the same size as an existing array.

a = [1 4;2 5;3 6];sz = size(a);x = nan(sz)
X =3×2NaN NaN NaN NaN NaN NaN

将前两行代码组合到单行中是一种常见模式。

x = nan(size(A));

Create a 1-by-3 vector ofNaN值whose elements are of typesingle

x = nan(1,3,'single')
X =1x3 single row vectorNaN NaN NaN

You can also specify the output type based on the type of another variable. Create a variablepof typesingle。这n, create a vector ofNaN值with the same size and type asp

p =单个([1 2 3]);x = nan(size(p),'like',p)
X =1x3 single row vectorNaN NaN NaN

Input Arguments

collapse all

方形矩阵的大小,指定为整数。

  • Ifn是0,然后Xis an empty matrix.

  • Ifnis negative, then it is treated as 0.

Data Types:double|single|int8|INT16|INT32|int64|uint8|uint16|uint32|uint64

Size of each dimension in a list, specified as separate integer arguments.

  • If the size of any dimension is 0, thenXis an empty array.

  • If the size of any dimension is negative, then it is treated as 0.

  • Beyond the second dimension,NaNignores trailing dimensions of length 1. For example,NaN(3,1,1)creates a 3-by-1 vector ofNaN值。

Data Types:double|single|int8|INT16|INT32|int64|uint8|uint16|uint32|uint64

Size of each dimension in a vector, specified as a row vector of integers.

  • If the size of any dimension is 0, thenXis an empty array.

  • If the size of any dimension is negative, then it is treated as 0.

  • Beyond the second dimension,NaNignores trailing dimensions of length 1. For example,南([3 1 1])creates a 3-by-1 vector ofNaN值。

Data Types:double|single|int8|INT16|INT32|int64|uint8|uint16|uint32|uint64

数据类型to create, specified as'double'或者'single'

数组的原型要创建,指定为数组。

Data Types:double|single
Complex Number Support:Yes

提示

  • x = nanreturns the scalar, typedouble, IEEE®representation of "not a number". The exact bit-wise hexadecimal representation of this value isfff8000000000000。MATLAB®保留替代的“非数字”状态NaNrepresentations and treats all representations equivalently. In some special cases, due to hardware limitations for example, MATLAB does not preserve the exact bit pattern of the alternate representations during computation, and instead uses the canonicalNaN先前描述的位模式。

  • NaN值are not equal to each other. As a result, comparison operations involvingNaNreturn false, except for the not equal operator〜=。For example,NaN == NaN返回逻辑0(false) butnan〜 = nan返回逻辑1(真的).

  • NaN值in a vector are treated as different unique elements. For example,unique([1 1 NaN NaN])returns the row vector[1 NaN NaN]

  • Use theisnan或者ismissing检测功能NaN数组中的值。这rmmissing功能检测和删除NaN值, and thefillmissing功能检测NaN价值并用非 - 取代它们NaN值。

Extended Capabilities

在R2006a之前引入