MATLAB: How to delete persistent variables in a timer fcn

clearMATLABpersistenttimer

Hi all,
I am using 3 persistent variables in a timer callback function. If I close the GUI (CloseRequestFcn) I want to delete the variable so that it is reinitialized if I start the programm again.
Actually I tried
clear timer_callback_fcn;
But that doesn't work. Moreover I tried
clear functions
This is working well but it doesn't seem to be the best way. Any ideas to improve?
Thank you!

Best Answer

Is timer_callback_fcn an M-file, a subfunction or a nested function? You can clear M-files only.
Instead of persistent variables, storing the data in the timer's UserData looks smarter. Then starting teh timer/GUI again, the data are reset automatically.