MATLAB: How to clear persistent variables

persistent variables

I am currently using a persistent variable within a function that I would like to clear at the end of the execution of a larger program. I am currently using "clear functions". This is causing some headaches during debugging since this clears my breakpoints as well. Is there a way to clear only the persistent variables? Better yet, is there a way to clear specific persistent variables?

Best Answer

you can use
clear functionName
and all the persistent vars in that function will be cleared (set to [])