MATLAB Answers

0

if there is startat, is there also stopat?

why is there a startat function for timer, but there is none for stopping (such as stopat *if there's any) ?
thank you..

  0 Comments

Sign in to comment.

Products

1 Answer

Answer by Walter Roberson
on 7 Feb 2011
 Accepted Answer

Because it is trivial to write your own?
stopat = @(Timer,stoptime) startat(timer('StartFcn', @(src,evt) stop(Timer)), stoptime);

  9 Comments

I tried to be clever about combining two commands into one anonymous function. It works more often than not, but this seems to be one of the "not" times.
At the moment I cannot think of a way to get around the problem while still using an anonymous function. Writing the function non-anonymously should be fine:
function stop_and_delete(src,evt,Timer)
stop(Timer);
delete(src);
end
Then
stopat = @(Timer,stoptime) startat(timer('TimerFcn', {@stop_and_delete, Timer}), stoptime);
Sir Walter, it works.. however, this warning went out..
*********************************************************
Warning: One or more timer objects were stopped before
deletion.
*********************************************************
The thing you said "not" times, maybe the result of that.. ^^ .. But still it worked.. thank you.. thumbs up..
@Jiro: Thanks also for the sharing of idea..it was helpful.. Thank you.

Sign in to comment.