randn

Array of randn values

Description

example

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

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

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

example

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

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

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

R = randn(n,'like',P) returns an n-by-n array with randn values in all elements and the same type and underlying class (data type) as the prototype array, P.

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

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

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

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

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

example

C = randn(n,codist) returns an n-by-n codistributed array with randn values in all elements and underlying class of double. 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 = randn(size1,...,sizeN,codist) returns a size1-by-...-by-sizeN codistributed array with randn values in all elements and underlying class of double.

C = randn(size,codist) returns a codistributed array which size is defined by the size vector size with randn values in all elements and underlying class of double.

C = randn(n,datatype,codist) returns an n-by-n codistributed array with randn values in all elements and underlying class of datatype. 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 = randn(size1,...,sizeN,datatype,codist) returns a size1-by-...-by-sizeN codistributed array with randn values in all elements and underlying class of datatype.

C = randn(size,datatype,codist) returns a codistributed array which size is defined by the size vector size with randn values in all elements and underlying class of datatype.

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

C = randn(___,codist,'like',P) creates a codistributed array of random integer values with the specified range, 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 randn values from 1 to 100, with underlying class double.

D = randn(1000,'distributed');

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

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

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

Create a 1000-by-1000 codistributed single matrix of randn values, distributed by its columns.

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

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

Create a 1000-by-1000 gpuArray of randn values with underlying class double:

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

Input Arguments

collapse all

Size of the generated array, specified as a scalar.

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

Size of each dimension, specified as a row vector of scalars. 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 random integers, returned as either a distributed array, a codistributed array, or a gpuArray.

Array of random integers, returned as a codistributed array.

Introduced in R2006b