Mercurial > hg > ishara
view sched/sched_at.m @ 44:3cedfd4549ef
Code added since initial check in.
author | samer |
---|---|
date | Tue, 13 Jan 2015 14:03:17 +0000 |
parents | f7fb679637ff |
children |
line wrap: on
line source
% sched_abs- Use one-shot timer to schedule action % % sched_abs:: timer, time, (timer, timer_event => void) => void. % % Can only be used on a stopped timer, whereas callback executes with % a running timer. function x=sched_abs(f,T,nout) if nargin<3, nout=nargout(f); end rc=cell(1,nout); tim=timer('TimerFcn',@(t,e)timfn,'StopFcn',@stopfn,'StartDelay',quant(0.001,T-nows)); start(tim); x=@()collect(); function timfn, [rc{:}]=f(); end function stopfn(t,e), timer_release(t); end function varargout=collect(), if isvalid(tim), wait(tim); end varargout=rc; end end