Matlab Clear Command
clear Clear variables and functions from memory.
clear removes all variables from the workspace.
clear VARIABLES does the same thing.
clear GLOBAL removes all global variables.
clear FUNCTIONS removes all compiled M- and MEX-functions.
clear ALL removes all variables, globals, functions and MEX links.
clear ALL at the command prompt also removes the Java packages
clear IMPORT removes the Java packages import list at the command
prompt. It cannot be used in a function.
clear CLASSES is the same as clear ALL except that class definitions
are also cleared. If any objects exist outside the workspace (say in
userdata or persistent in a locked m-file) a warning will be issued
and the class definition will not be cleared. clear CLASSES must be
used if the number or names of fields in a class are changed.
clear VAR1 VAR2 … clears the variables specified. The wildcard
character ‘*’ can be used to clear variables that match a pattern.
For instance, clear X* clears all the variables in the current
workspace that start with X.
If X is global, clear X removes X from the current workspace,
but leaves it accessible to any functions declaring it global.
clear GLOBAL X completely removes the global variable X.
clear FUN clears the function specified. If FUN has been locked
by MLOCK it will remain in memory. Use a partial path (see
PARTIALPATH) to distinguish between different overloaded versions of
FUN. For instance, ‘clear inline/display’ clears only the INLINE
method for DISPLAY, leaving any other implementations in memory.
clear ALL, clear FUN, or clear FUNCTIONS also have the side effect of
removing debugging breakpoints and reinitializing persistent variables
since the breakpoints for a function and persistent variables are
cleared whenever the m-file changes or is cleared.
Use the functional form of CLEAR, such as clear(‘name’),
when the variable name or function name is stored in a string.
See also who, whos, mlock, munlock, persistent.