clear

Obliterates variable(s) from memory in the current session of the application.

Syntax

clear

clear global

clear(x)

Inputs

global (optional)
Argument which will obliterate all global variables from memory.
Type: Command name.
x (optional)
Name of the variable to obliterate. This can also contain a wildcard pattern '*', which will obliterate all variables matching the pattern.
Type: string

Examples

Obliterates all variables from memory:
global globalVariable;
testInteger = 24;
testString = 'This is a test string';
clear
who
No variables in current scope in call to function who at line number 1
Obliterates only global variables from memory:
global globalVariable;
testInteger = 24;
testString = 'This is a test string';
clear global
who
Variables in current scope:
testInteger
testString
Obliterates variable associated with the given name from memory:
global globalVariable;
testInteger = 24;
testString = 'This is a test string';
clear('testInteger')
who
Variables in current scope:
globalVariable
testString
Obliterates variables associated with names, matching the given pattern from memory:
global globalVariable;
testInteger = 24;
testString1 = 'This is string 1';
testString2 = 'This is an example for the command clear';
clear('*ring*')
who
Variables in current scope:
globalVariable
testInteger

Comments

If no arguments are passed, all variables are obliterated from memory. If an optional argument, global, is passed, only global variables are obliterated from memory. If an optional argument x is passed, the variable associated with the name x will be obliterated. x may also contain a wildcard pattern '*', which will obliterate all variables with names matching the wildcard pattern from memory.