Mercurial > hg > ishara
view graphics/animseq.m @ 47:82075c94eed1
adding a bunch of stuff, including graphics and pitch toolboxes.
author | samer |
---|---|
date | Sat, 17 Jan 2015 15:20:35 +0000 |
parents | |
children |
line wrap: on
line source
function varargout=animdata(upd,X,varargin) % animdata - use arbitrary function to animate data sequence % % animdata :: % A->unit ~'function to update animation', % seq A ~'data sequence to plot', % options { % pre :: action / @nop ~'called before each plot'; % post :: action / @nop ~'called after eacn plot'; % defer :: bool / 0 ~'if 1, just return state transformer function'; % fps :: nonneg / 0 ~'if positive, used timed iterator at this rate' % } % -> (A->A,handle) ~'action to iterate', % A ~'initial state'. opts=prefs('fps',0,'pre',@nop,'post',@nop,'defer',0,varargin{:}); if opts.defer, stfn=@plotnext_h; elseif opts.fps>0 stfn=@plotnext; API=iterate_timed(stfn,X,1/opts.fps,opts); if nargout==1, varargout{1}=API; end else stfn=@plotnext; iterate(stfn,X,opts); if nargout==1, varargout{1}={stfn,X}; else varargout={stfn,X}; end end function S=plotnext(S), upd(head(S)); S=next(S); end function [S,h]=plotnext_h(S), upd(head(S)); S=next(S); if nargout>1, h=get(gca,'title'); end end end