CLEAR Clear or Delete a Variable
Section: Inspection Functions
UsageClears a set of variables from the current context, or alternately, delete all variables defined in the current context. There are several formats for the function call. The first is the explicit form in which a list of variables are provided:
clear a1 a2 ...
The variables can be persistent or global, and they will be deleted. The second form
clears all variables and libraries from the current context. Alternately, you can use the form:
which will unload any libraries or DLLs that have been
Optionally, you can specify that persistent variables should be cleared via:
and similarly for global variables:
You can use
to clear all definitions of user-defined classes.
With no arguments,
clear defaults to clearing
ExampleHere is a simple example of using
clearto delete a variable. First, we create a variable called
--> a = 53 a = 53
Next, we clear
a using the
clear function, and verify that it is deleted.
--> clear a --> a Error: Undefined function or variable a