TimerFcn in gui from one function to another
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a gui that interfaces with some TDT software to play out electrical stimuli. I want to have an intertrial interval using a timer between trials. Essentially the timer is called at the end of a function and the TimerFcn is to call a different function.
So far, I have gone with creating the timer in the OpeningFcn:
%PUTTING IN THE TIMER
handles.gotimer = timer('TimerFcn',@(hObject,eventdata)GoButton_Callback(hObject, eventdata, handles),'StartDelay',15);
In the first function I call (GoButton_Callback), which is then the function to initialize another trial as well, I stop the timer:
%stop the timer
stop(handles.gotimer)
guidata(hObject,handles);
That function then calls one of my playback functions, at the end of which I run the timer and go back to the GoButton:
if rep_num < 65;
start(handles.gotimer);
guidata(hObject,handles);
end
At this point, the GoButton function goes to stop the timer (see above), and I get an error:
??? Error while evaluating TimerFcn for timer 'timer-7'
Reference to non-existent field 'gotimer'.
I should note that the number of the timer does seem to be creeping up, so I'm wondering if I keep creating another timer object. Anyone have ideas?
0 commentaires
Réponses (1)
Sean de Wolski
le 16 Juil 2012
As for the timers incrementing count. This will happen. Make sur eyou delete your timers when you are done with them!
t = timerfind;
or
t = timerfindall;
And:
if ~isempty(t)
stop(t)
delete(t);
end
0 commentaires
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!