clear
Remove items from workspace, freeing up system memory
Description
clear
removes all variables from the current
workspace, releasing them from system memory.
clear
removes the variables,
scripts, functions, or MEX functions name1 ... nameN
name1 ... nameN
from
memory.
clear -regexp
removes
all variables that match any of the regular expressions listed. This
option only removes variables.expr1 ... exprN
Examples
Input Arguments
Tips
Calling
clear all
,clear classes
, andclear functions
decreases code performance, and is usually unnecessary.To clear one or more specific variables from the current workspace, use
clear
.name1 ... nameN
To clear all variables from the current workspace, use
clear
orclearvars
.To clear all global variables, use
clear global
orclearvars –global
.To clear a particular class, use
clear
.myClass
To clear a particular function or script, use
clear
.functionName
To clear all MEX functions, use
clear mex
.
The
clear
function can remove variables that you specify. To remove all except a few specified variables, useclearvars
instead.If you clear the handle of a figure or graphics object, the object itself is not removed. Use
delete
to remove objects. On the other hand, deleting an object does not remove the variable (if any) used for storing its handle.The
clear
function does not clear Simulink® models. Usebdclose
instead.The
clear
function does not clear persistent variables in local or nested functions.On UNIX® systems,
clear
does not affect the amount of memory allocated to the MATLAB process.
Extended Capabilities
Version History
Introduced before R2006a