out of scope timer or not saved to variable

3 次查看(过去 30 天)
delete a timer that was not declared to a variable
start(timer('TimerFcn',@callbckfcn, 'StartDelay', 1, 'Period',5, 'ExecutionMode', 'fixedRate'));
delete a timer that was declared inside a function that has terminated
function fcn
t1 = timer('TimerFcn',@callbckfcn, 'StartDelay', 1, 'Period',5, 'ExecutionMode', 'fixedRate');
start(t1);
end

采纳的回答

Paulo Silva
Paulo Silva 2011-8-25
delete(timerfindall) %if you only have that timer
%timerfindall is a MATLAB function
  2 个评论
Ali Omar
Ali Omar 2011-8-25
that was fast, precise and did the trick..... thanx
Paulo Silva
Paulo Silva 2011-8-25
You can also create timers with something in their Tag property and find them with timerfind
timer('TimerFcn','disp(1)', 'StartDelay', 1,...
'Period',5, 'ExecutionMode', 'fixedRate','Tag','MyTimer')
%just in case it's running (no warnings using the delete function)
stop(timerfind('Tag','MyTimer'))
delete(timerfind('Tag','MyTimer')) %it's stopped so you can now delete it

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by