If you want to clear persistent from outside the function in which it is defined, you need to clear the function itself:
clear functionNameWithPersistentVariable
Or clear all ( unlocked ) functions from memory:
clear functions
If the function in question is actually a method of the class class , you may need to use clear classes . See also this table in the clear documentation.
In the function itself, you can use whos and something like the sentences in this Matlab Central answer . Unfortunately, I do not know of any elegant documented way to search or list functions or constant variables that are currently in memory.
source share