Mercurial > hg > ishara
view signals/@signal/length.m @ 6:0ce3c2070089
Removed duplicate code and fixed doc in timed_action.
author | samer |
---|---|
date | Mon, 14 Jan 2013 14:33:37 +0000 |
parents | 289445d368a7 |
children |
line wrap: on
line source
% length - length of finite signal function n=length(sig,varargin) opts=prefs('chunk',1024,'init',2,'grow',2,'max',1e12,varargin{:}); s=construct(sig); try % to make sure we dispose of s once opened chunk=uint64(opts.chunk); n=uint64(0); CHUNK=1:chunk; r=s.reader(opts.chunk); dummy=[]; rem=0; while rem==0 [dummy,rem]=r(); n=n+chunk; if n>opts.max, error('maximum length exceeded'); end end n=n-uint64(rem); % remove rem samples from end catch ex s.dispose(); rethrow(ex); end s.dispose(); n=double(n); end