FUNCTION REFERENCE
clear
Remove variables from the workspace, or drop cached functions and classes.
Remove variables from the workspace, or drop cached functions and classes.
Syntax
clearSyntax
clear A BSyntax
clear('A', 'B')Syntax
clear global [names]Syntax
clear allSyntax
clear functionsSyntax
clear classesSyntax
clear importSyntax
clear javaSyntax
clear mexWith no names it removes every variable in the current workspace. Names must be literal text. A name that is not a variable unloads the function file of that name and resets its persistent variables. clear global removes global variables: every global, or only the names that follow. clear all removes current-workspace variables, every global, the persistent variables of functions that are not running, cached function files, private-folder and class-method lookups, cached class definitions, and, at the Command Window only (not inside a script or function), the import list. Built-in functions, the search path, figures and the current folder stay. clear functions drops cached function files and their persistent variables; workspace variables stay. clear classes removes current-workspace variables and cached class definitions. A class that still has an instance, for example in a global, is kept together with its superclasses, and a warning is shown. clear import empties the import list. It works at the Command Window only. clear java and clear mex are accepted and do nothing.
Example
clear A B % removes A and BExample
clear allDifferences from MATLAB: clear all also drops cached class definitions (MATLAB clear all does not). clear classes keeps globals, persistent variables and cached function files (MATLAB clears them). There is no Java or MEX, so clear java and clear mex change nothing (MATLAB clear java also clears variables, functions and globals). clear -regexp is rejected. mlock is not supported; a function that is running stays loaded. clear import works only at the Command Window.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.