Mercurial > hg > ishara
view general/algo/iterate_sched.m @ 4:e44f49929e56
Adding reorganised general toolbox, now in several subdirectories.
author | samer |
---|---|
date | Sat, 12 Jan 2013 19:21:22 +0000 |
parents | |
children |
line wrap: on
line source
function tm=iterate_sched(nextfn,X,T,varargin) % iterate_sched - Iterate function under control of timer % % iterate_sched :: % (A=>A) ~'state transformer action', % A ~'initial state', % real ~'time between updates in seconds' % options { % drawnow :: {0,1} /0 ~'call drawnow after each iteration'; % busy_mode :: {'queue','drop'} /'queue' ~'See TIMER'; % its :: natural / inf ~'iteration limit' % -> timer. opts=prefs('its',inf,'drawnow',0,'busy_mode','queue','props',{},varargin{:}); if opts.drawnow, post=@drawnow; else post=@nop; end tm=rsched(@action,nows,T,opts.its,iterdata(nextfn,X)); function [err,s]=action(t_sched,dt,s) err=nows-t_sched; s=nextfn(s); post(); end end