Main Content

NaN

Create array of Not-a-Numbers for GPU or distributed arrays

Description

example

A = NaN(n,arraytype) returns an n-by-n matrix with underlying class of double, NaN values in all elements, and the type specified by arraytype.

A = NaN(size1,...,sizeN,arraytype) returns a size1-by-...-by-sizeN matrix with underlying class of double, NaN values in all elements, and the type specified by arraytype.

A = NaN(size,arraytype) returns an array which size is defined by the size vector size with underlying class of double, NaN values in all elements, and the type specified by arraytype.

example

A = NaN(n,datatype,arraytype) returns an n-by-n matrix with underlying class of datatype, NaN values in all elements, and the type specified by arraytype.

A = NaN(size1,...,sizeN,datatype,arraytype) returns a size1-by-...-by-sizeN matrix with underlying class of datatype, NaN values in all elements, and the type specified by arraytype.

A = NaN(size,datatype,arraytype) returns an array which size is defined by the size vector size with underlying class of datatype, NaN values in all elements, and the type specified by arraytype.

A = NaN(n,'like',P) returns an n-by-n array of NaN values with the same underlying class and type as the prototype array, P.

A = NaN(size1,...,sizeN,'like',P) returns a size1-by-...-by-sizeN array of NaN values with the same underlying class and type as the prototype array, P.

A = NaN(size,'like',P) returns an array of NaN values which size is defined by the size vector size with the same underlying class and type as the prototype array, P.

A = NaN(n,datatype,'like',P) returns an n-by-n array with underlying class of datatype, NaN values in all elements, and the same type as the prototype array, P.

A = NaN(size1,...,sizeN,datatype'like',P) returns a size1-by-...-by-sizeN array with underlying class of datatype, NaN values in all elements, and the same type as the prototype array, P.

A = NaN(size,datatype,'like',P) returns an array which size is defined by the size vector size with underlying class of datatype, NaN values in all elements, and the same type as the prototype array, P.

C = NaN(n,codist) returns an n-by-n codistributed array with underlying class of double and NaN values in all elements. The codistributor object codist specifies the distribution scheme for creating the codistributed array. For information on constructing codistributor objects, see the reference pages for codistributor1d and codistributor2dbc.

C = NaN(size1,...,sizeN,codist) returns a size1-by-...-by-sizeN codistributed array with underlying class of double and NaN values in all elements. The codistributor object codist specifies the distribution scheme for creating the codistributed array. For information on constructing codistributor objects, see the reference pages for codistributor1d and codistributor2dbc.

C = NaN(size,codist) returns a codistributed array which size is defined by the size vector size with underlying class of double and NaN values in all elements. The codistributor object codist specifies the distribution scheme for creating the codistributed array. For information on constructing codistributor objects, see the reference pages for codistributor1d and codistributor2dbc.

C = NaN(n,datatype,codist) returns an n-by-n codistributed array with underlying class of datatype and NaN values in all elements. The codistributor object codist specifies the distribution scheme for creating the codistributed array. For information on constructing codistributor objects, see the reference pages for codistributor1d and codistributor2dbc.

example

C = NaN(size1,...,sizeN,datatype,codist) returns a size1-by-...-by-sizeN codistributed array with underlying class of datatype and NaN values in all elements. The codistributor object codist specifies the distribution scheme for creating the codistributed array. For information on constructing codistributor objects, see the reference pages for codistributor1d and codistributor2dbc.

C = NaN(size,datatype,codist) returns a codistributed array which size is defined by the size vector size with underlying class of datatype and NaN values in all elements. The codistributor object codist specifies the distribution scheme for creating the codistributed array. For information on constructing codistributor objects, see the reference pages for codistributor1d and codistributor2dbc.

C = NaN(___,codist,'noCommunication') specifies that no interworker communication is to be performed when constructing a codistributed array, skipping some error checking steps.

C = NaN(___,codist,'like',P) creates a codistributed array of NaN values with the specified size, underlying class, and distribution scheme. If either the class or codistributor argument is omitted, the characteristic is acquired from the codistributed array P.

Examples

collapse all

Create a 1000-by-1000 distributed array of NaN values with underlying class double.

D = NaN(1000,'distributed');

Create a 1000-by-1000 codistributed double matrix of NaN values, distributed by its second dimension (columns).

spmd(4)
    C = NaN(1000,'codistributed');
end

With four workers, each worker contains a 1000-by-250 local piece of C.

Create a 1000-by-1000 codistributed uint16 matrix of NaN values, distributed by its columns.

spmd(4)
    codist = codistributor('1d',2,100*[1:numlabs]);
    C = NaN(1000,1000,'single',codist);
end

Each worker contains a 100-by-labindex local piece of C.

Create a 1000-by-1000 gpuArray of NaNvalues, with underlying class double:

G = NaN(1000,'double','gpuArray');

Input Arguments

collapse all

Size of the generated array, specified as an integer value.

Size of each dimension of the generated array, specified as separate arguments of two or more integer values.

Size of each dimension, specified as a row vector of integer values. Each element of this vector indicates the size of the corresponding dimension.

Type of the generated array, specified as either 'distributed', 'codistributed', or 'gpuArray'.

Underlying class of the array, that is the data type of its elements, specified as either 'double' or 'single'.

Distribution scheme for creating the codistributed array, specified as a codistributor object. For information on constructing codistributor objects, see the reference pages for codistributor1d and codistributor2dbc. To use the default distribution scheme, you can specify a codistributor constructor without arguments.

Prototype of array to create, specified as an array.

Output Arguments

collapse all

Array of NaN values, returned as either a distributed array, a codistributed array, or a gpuArray.

Array of NaN values, returned as a codistributed array.

See Also

| | | | |

Introduced in R2006b