Mercurial > hg > ishara
view arrows/asweep.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | 672052bd81f8 |
children |
line wrap: on
line source
% asweep - Arrow which writes inputs consecutively into a buffer % % asweep :: % W:natural ~'width of buffer', % A ~'a value to pad buffer with' % -> arrow({[[N,1]->A]}, {[[N,W]->A]}, [[N,W]->A]). % % This arrow expects column vectors of some type A. It % maintains an array of width W and writes the input % vectors into its columns, starting at column 1 and % increasing, wrapping round at column W. This can be % used, eg to create a sweeping (not scrolling) line % plot of the last W values of some signal: % source * asweep(200,nan) * plotter % % See also awindow. function a=asweep(width,pad) a=loop(@windowfn,@(sz){1,repmat(pad,sz(1),width)}); function [out,st]=windowfn(in,st) for i=1:size(in,2) st{2}(:,st{1}) = in(:,i); st{1} = 1+mod(st{1},width); end out=st{2}; end end