clear

March 6th, 2008 Posted in Functions

clear Clear variables and from memory.
clear removes all variables from the workspace.
clear VARIABLES does the same thing.
clear GLOBAL removes all global variables.
clear removes all compiled M- and MEX-.

clear ALL removes all variables, globals, and MEX links.
clear ALL at the command prompt also removes the Java packages
import list.
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. 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 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.
instance, clear X* clears all the variables in the current
workspace that start with X.

X is global, clear X removes X from the current workspace,
but leaves it accessible to any declaring it global.
clear GLOBAL X completely removes the global variable X.

clear FUN clears the function specified. 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. instance, ‘clear inline/display’ clears only the INLINE
method DISPLAY, leaving any other implementations in memory.

clear ALL, clear FUN, or clear also have the side effect of
removing debugging breakpoints and reinitializing persistent variables
since the breakpoints 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.

Related posts

Leave a Reply

You must be logged in to post a comment.