User`s guide
3 Single Program Multiple Data (spmd)
3-14
X = 5;
spmd
eval('X');
end
Similarly, you cannot clear variables from a worker's workspace by executing clear
inside an spmd statement:
spmd; clear('X'); end
To clear a specific variable from a worker, clear its Composite from the client workspace.
Alternatively, you can free up most of the memory used by a variable by setting its value
to empty, presumably when it is no longer needed in your spmd statement:
spmd
<statements....>
X = [];
end
Examples of some other functions that violate transparency are evalc, evalin, and
assignin with the workspace argument specified as 'caller'; save and load, unless
the output of load is assigned to a variable.
MATLAB does successfully execute eval and evalc statements that appear in functions
called from the spmd body.
Nested Functions
Inside a function, the body of an spmd statement cannot make any direct reference to a
nested function. However, it can call a nested function by means of a variable defined as
a function handle to the nested function.
Because the spmd body executes on workers, variables that are updated by nested
functions called inside an spmd statement do not get updated in the workspace of the
outer function.
Anonymous Functions
The body of an spmd statement cannot define an anonymous function. However, it can
reference an anonymous function by means of a function handle.
Nested spmd Statements
The body of an spmd statement cannot directly contain another spmd. However, it can
call a function that contains another spmd statement. The inner spmd statement does not