Create Composite object


C = Composite()
C = Composite(nlabs)


C = Composite() creates a Composite object on the client using workers from the parallel pool. The actual number of workers referenced by this Composite object depends on the size of the pool and any existing Composite objects. Generally, you should construct Composite objects outside any spmd statement.

C = Composite(nlabs) creates a Composite object on the parallel pool set that matches the specified constraint. nlabs must be a vector of length 1 or 2, containing integers or Inf. If nlabs is of length 1, it specifies the exact number of workers to use. If nlabs is of size 2, it specifies the minimum and maximum number of workers to use. The actual number of workers used is the maximum number of workers compatible with the size of the parallel pool, and with other existing Composite objects. An error is thrown if the constraints on the number of workers cannot be met.

A Composite object has one entry for each lab; initially each entry contains no data. Use either indexing or an spmd block to define values for the entries.


  • A Composite is created on the workers of the existing parallel pool. If no pool exists, Composite will start a new parallel pool, unless the automatic starting of pools is disabled in your parallel preferences. If there is no parallel pool and Composite cannot start one, the result is a 1-by-1 Composite in the client workspace.


Create a Composite object with no defined entries, then assign its values:

    c = Composite();  % One element per worker in the pool
    for ii = 1:length(c)
        % Set the entry for each worker to zero
        c{ii} = 0;    % Value stored on each worker

See Also


Was this topic helpful?