Mercurial > hg > ishara
view sequences/@subsampdata/subsampdata.m @ 2:7357e1dc2ad6
Simplified scheduler library with new schedule representation.
author | samer |
---|---|
date | Sat, 22 Dec 2012 16:17:51 +0000 |
parents | 672052bd81f8 |
children |
line wrap: on
line source
function d=subsampdata(a,b,varargin) % subsampdata - Use arbitrary function to test and filter elements of another sequence % % subsampdata :: % natural ~ sample rate, % data(A), ~ source data, % ... ~ options) % -> data(A). % % Options % 'datafn':: Data A->A ~ override function to get data % 'stringfn':: Data A->String ~ override conversion to string % 'nextfn':: Data A->(Data A | []) ~ override next function % % Methods % % source :: filterdata(A) -> data(A). if nargin==0, a=subsampdata(1,singleton(0)); end if isa(a,'subsampdata'), d=a; else d.n=a; opts=prefs('datafn',@datafn,'stringfn',@stringfn,'sizecheck',0,varargin{:}); opts.nextfn=@nextfn; d=class(d,'subsampdata',ddata(b,size(b),opts)); end function x=datafn(d), x=head(source(d)); function s=stringfn(d), s=sprintf('subsamp(%d)',tostring(d.n)); function o=nextfn(o) for i=1:o.n o=next_c(o); if isempty(o), break; end end