How can I put a timer in my GUI?
1 次查看(过去 30 天)
显示 更早的评论
I want a code that is counting all the time since I press the push button. If the time is 3 s I want to display a message if the time is between 3s and 6s I want another message and between 6s and 20s the final message.
Could someone help me?
0 个评论
采纳的回答
KSSV
2017-3-28
t1 = tic ;
count =0 ;
while count ==0
if abs(3-toc(t1))<=10^-5
disp('time is 3S') ;
elseif toc(t1)>3 && toc(t1)<6
disp('time is between 3S and 6S')
elseif toc(t1)>6 && toc(t1)<20
disp('time between 6S and 20S')
end
end
toc(t1)
5 个评论
KSSV
2017-3-28
You may need not to use this while loop....when you press button 1, call the tic, when you press the second button call the toc...it gives time..depending on it's value display the message.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!