Documentation Center

  • Trial Software
  • Product Updates

true

Array of logical 1 (true)

Syntax

T = true(sz,arraytype)

T = true(sz,'like',P)

C = true(sz,codist)
C = true(sz,___,codist,'noCommunication')
C = true(sz,___,codist,'like',P)

Description

T = true(sz,arraytype) creates a matrix with true values in all elements.

The size and type of array are specified by the argument options according to the following table.

ArgumentValuesDescriptions
sznSpecifies size as an n-by-n matrix.
m,n or [m n]Specifies size as an m-by-n matrix.
m,n,...,k or [m n ... k]Specifies size as an m-by-n-by-...-by-k array.
arraytype'distributed'Specifies distributed array.
'codistributed'Specifies codistributed array, using the default distribution scheme.
'gpuArray'Specifies gpuArray.

T = true(sz,'like',P) creates an array of true values with the same type as array P.

C = true(sz,codist) creates a codistributed array of true values with the specified size. 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. To use the default distribution scheme, you can specify a codistributor constructor without arguments. For example:

spmd
    C = true(8,codistributor1d());
end

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

C = true(sz,___,codist,'like',P) creates a codistributed array of true values with the specified size and distribution scheme. If the codistributor argument is omitted, the distribution scheme is taken from the codistributed array P.

Examples

Create Distributed True Matrix

Create a 1000-by-1000 distributed array of trues with underlying class double:

D = true(1000,'distributed');

Create Codistributed True Matrix

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

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

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

Create a 1000-by-1000 codistributed matrix of trues, distributed by its columns.

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

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

Create gpuArray True Matrix

Create a 1000-by-1000 gpuArray of trues:

G = true(1000,'gpuArray');

See Also

| | | | | |

Was this topic helpful?