Remove objects from MATLAB workspace
An object or an array of objects.
clear obj removes
from the MATLAB® workspace.
To remove variables from the workspace of pool or cluster workers, use
clear to preserve workspace transparency. If you try to
clear directly in a
spmd block, you encounter an error. For more information,
see Ensure Transparency in parfor-Loops or spmd Statements.
This example creates two job objects on the MATLAB Job Scheduler
jm. The variables for these job
objects in the MATLAB workspace are
job1 is copied to a new variable,
job2 are cleared from the MATLAB workspace. The job objects are then restored to the workspace from the
Jobs property as
j2, and the first job in the MATLAB Job Scheduler is shown to be identical to
while the second job is not.
c = parcluster(); delete(c.Jobs) % Assure there are no jobs job1 = createJob(c); job2 = createJob(c); job1copy = job1; clear job1 job2; j1 = c.Jobs(1); j2 = c.Jobs(2); isequal (job1copy,j1)
ans = 1
ans = 0
obj references an object in the cluster, it is cleared from
the workspace, but it remains in the cluster. You can restore
to the workspace with the
findTask function; or with the