MATLAB Function Reference
  Go to function:
    Search    Help Desk 
clear    See Also

Remove items from memory

Syntax

clear keyword

Description

clear clears all variables from the workspace.

clear name removes just the M-file or MEX-file function or variable name from the workspace. A MATLABPATH relative partial pathname is permitted. If name is global, it is removed from the current workspace, but left accessible to any functions declaring it global. If name has been locked by mlock, it will remain in memory.

clear name1 name2 name3 removes name1, name2, and name3 from the workspace.

clear global name removes the global variable name.

clear keyword clears the items indicated by keyword.

Keyword
Items Cleared
functions
Clears all the currently compiled M-functions from memory.
variables
Clears all variables from the workspace.
mex
Clears all MEX-files from memory.
global
Clears all global variables.
all
Removes all variables, functions, and MEX-files from memory, leaving the workspace empty.
classes
Works the same as clear all, but also clears class definitions. If any objects exist outside the workspace (e.g., 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.

Remarks

You can use wildcards (*) to remove items selectively. For instance, clear my* removes any variables whose names begin with the string "my." The function form of the syntax, clear('name'), is also permitted.

Limitations

clear does not affect the amount of memory allocated to the MATLAB process under UNIX.

See Also

mlock, munlock, pack



[ Previous | Help Desk | Next ]