Define persistent variable
Syntax
persistent X Y Z
Description
persistent X Y Z
defines X
, Y
, and Z
as persistent in scope, so that X, Y, and Z maintain their values from one call to the next. persistent
can be used within a function only.
Persistent variables are cleared when the M-file is cleared from memory or when the M-file is changed. To keep an M-file in memory until MATLAB quits, use mlock
. If the persistent variable does not exist the first time you issue the persistent
statement, it is initializied to the empty matrix.
It is an error to declare a variable persistent if a variable with the same name exists in the current workspace.
By convention, persistent variable names are often long with all capital letters (not required).
See Also
clear
, global
, mislocked
, mlock
, munlock
[ Previous | Help Desk | Next ]