Skip to Main Content Skip to Search
Product Documentation

exist - Check whether Composite is defined on labs

Syntax

h = exist(C, labidx)
h = exist(C)

Description

h = exist(C, labidx) returns true if the entry in Composite C has a defined value on the lab with labindex labidx, false otherwise. In the general case where labidx is an array, the output h is an array of the same size as labidx, and h(i) indicates whether the Composite entry labidx(i) has a defined value.

h = exist(C) is equivalent to h = exist(C, 1:length(C)).

If exist(C, labidx) returns true, C(labidx) does not throw an error, provided that the values of C on those labs are serializable. The function throws an error if the lab indices are invalid.

Examples

Define a variable on a random number of labs. Check on which labs the Composite entries are defined, and get all those values:

 spmd
   if rand() > 0.5
       c = labindex;
   end
 end
 ind = exist(c);
 cvals = c(ind);

See Also

Composite

  


Free Parallel Computing Interactive Kit

See how to solve large problems with minimal effort and reduce simulation time.

Get free kit

Trials Available

Try the latest versions of parallel computing products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS