List/view/clear persistent variables in Matlab

空扰寡人 提交于 2019-12-22 05:47:09

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/19800424/list-view-clear-persistent-variables-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!