This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Remove objects from MATLAB workspace


clear obj



An object or an array of objects.


clear obj removes obj from the MATLAB® workspace.


Use parfevalOnAll instead of parfor or spmd if you want to use clear. This preserves workspace Ensure Transparency in parfor-Loops.


This example creates two job objects on the MATLAB job scheduler jm. The variables for these job objects in the MATLAB workspace are job1 and job2. job1 is copied to a new variable, job1copy; then job1 and job2 are cleared from the MATLAB workspace. The job objects are then restored to the workspace from the job object's Jobs property as j1 and j2, and the first job in the MJS is shown to be identical to job1copy, 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 =
isequal (job1copy,j2)
ans =


If obj references an object in the cluster, it is cleared from the workspace, but it remains in the cluster. You can restore obj to the workspace with the parcluster, findJob, or findTask function; or with the Jobs or Tasks property.

Introduced before R2006a

Was this topic helpful?