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 ... nameNname1 ... 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 functionsdecreases code performance, and is usually unnecessary.To clear one or more specific variables from the current workspace, use
clear.name1 ... nameNTo clear all variables from the current workspace, use
clearorclearvars.To clear all global variables, use
clear globalorclearvars –global.To clear a particular class, use
clear.myClassTo clear a particular function or script, use
clear.functionNameTo clear all MEX functions, use
clear mex.
The
clearfunction can remove variables that you specify. To remove all except a few specified variables, useclearvarsinstead.If you clear the handle of a figure or graphics object, the object itself is not removed. Use
deleteto remove objects. On the other hand, deleting an object does not remove the variable (if any) used for storing its handle.The
clearfunction does not clear Simulink® models. Usebdcloseinstead.The
clearfunction does not clear persistent variables in local or nested functions.On UNIX® systems,
cleardoes not affect the amount of memory allocated to the MATLAB process.
Extended Capabilities
Version History
Introduced before R2006a