samer@10: % sched_abs- Use one-shot timer to schedule action samer@10: % samer@10: % sched_abs:: timer, time, (timer, timer_event => void) => void. samer@10: % samer@10: % Can only be used on a stopped timer, whereas callback executes with samer@10: % a running timer. samer@10: samer@10: function x=sched_abs(f,T,nout) samer@10: if nargin<3, nout=nargout(f); end samer@10: rc=cell(1,nout); samer@10: tim=timer('TimerFcn',@(t,e)timfn,'StopFcn',@stopfn,'StartDelay',quant(0.001,T-nows)); samer@10: start(tim); samer@10: x=@()collect(); samer@10: samer@10: function timfn, [rc{:}]=f(); end samer@10: function stopfn(t,e), timer_release(t); end samer@10: function varargout=collect(), samer@10: if isvalid(tim), wait(tim); end samer@10: varargout=rc; samer@10: end samer@10: end