How to enable a button after x seconds in MATLAB GUI?
15 views (last 30 days)
Show older comments
Matlab Help Seeker on 25 Jun 2011
I am recording an audio. I have a start button and a stop button in GUI. When someone clicks start, the audio starts getting recorded.
Now, I want to enable the stop button only after x seconds. Where x could be 0.5 seconds, 1 seconds or whatever. How could I know that x seconds have passed and now its time to turn on the stop button.
Basically, I don't know how to start a clock and obtain its value. Can someone please help me with it?
t = timer('TimerFcn','nan;','StopFcn',@endtimer, 'startdelay',... 2,'ExecutionMode','singleshot');
pbh1 = uicontrol(gcf,'Style','pushbutton','String','Start timer',...
'Position',[10 90 60 40],...
pbh2 = uicontrol(gcf,'Style','pushbutton','String','Button',...
'Position',[10 30 60 40],...
'enable','off','callback','disp(''You pressed the Button'')');
disp('timer stopped, Button enabled')
%code to start recording and start record
%now the user can click again on the button
More Answers (1)
Fangjun Jiang on 25 Jun 2011
Find more on Measurements and Spatial Audio in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!