Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List/view/clear persistent variables in Matlab

How does one list/view/clear persistent variables in MATLAB? I'd like to see persistent variables not for a particular function, but for all functions that have persistent variables currently in memory.

I've tried things like whos('persistent') and whos('global') with no luck.

like image 736
Nick Avatar asked Nov 05 '13 22:11

Nick


1 Answers

If you want to clear a persistent from outside of the function within which it's defined, then 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 a class, you may need to use clear classes instead. See also this table in the documentation for clear.

Within the function itself you may be able to use whos and something like the suggestion in this Matlab Central answer. Unfortunately, I don't know of any elegant documented way to find or list functions or persistent variables that are currently in memory.

like image 143
horchler Avatar answered Sep 29 '22 09:09

horchler