## Documentation Center |

Create codistributed array from replicated local data

`C = codistributed(X)C = codistributed(X, codist)C = codistributed(X, codist, lab)C = codistributed(C1, codist)`

`C = codistributed(X)` distributes a replicated `X` using
the default codistributor. `X` must be a replicated
array, that is, it must have the same value on all workers. `size(C)` is
the same as `size(X)`.

`C = codistributed(X, codist)` distributes
a replicated `X` using the codistributor `codist`. `X` must
be a replicated array, namely it must have the same value on all workers. `size(C)` is
the same as `size(X)`. For information on constructing
codistributor objects, see the reference pages for `codistributor1d` and `codistributor2dbc`.

`C = codistributed(X, codist, lab)` distributes
a local array `X` that resides on the worker identified
by `lab`, using the codistributor `codist`.
Local array `X` must be defined on all workers, but
only the value from `lab` is used to construct `C`. `size(C)` is
the same as `size(X)`.

`C = codistributed(C1, codist)` where the
input array `C1` is already a codistributed array,
redistributes the array `C1` according to the distribution
scheme defined by codistributor `codist`. This is
the same as calling `C = redistribute(C1, codist)`.
If the specified distribution scheme is that same as that already
in effect, then the result is the same as the input.

Create a 1000-by-1000 codistributed array C1 using the default distribution scheme.

spmd N = 1000; X = magic(N); % Replicated on every lab C1 = codistributed(X); % Partitioned among the workers end

Create a 1000-by-1000 codistributed array C2, distributed by rows (over its first dimension).

spmd N = 1000; X = magic(N); C2 = codistributed(X, codistributor1d(1)); end

`codistributor1d` | `codistributor2dbc` | `gather` | `getLocalPart` | `globalIndices` | `redistribute` | `size` | `subsasgn` | `subsref`

Was this topic helpful?