samer@0: % adyniir - Apply dynamic IIR filter to input signal samer@0: % samer@0: % adyniir :: arrow({[[K,N+1]], [[K,M]]}, {[[K,M]]}, [[K,N]]). samer@0: % samer@0: % N is the order of the IIR filter samer@0: % K is the number of independent channels to filter. samer@0: % M is the number of consecutive samples in input signal samer@0: samer@0: function o=adyniir samer@0: o=loop1(2,1,@(s1,s2)deal( ifx(s2(2)==1,@next1,@nextm), zeros(s1(1),s1(2)-1))); samer@0: end samer@0: samer@0: samer@0: function [y,yp]=next1(a,x,yp) samer@0: y=x-sum(a(:,2:end).*yp,2); samer@0: yp=[y,yp(:,1:end-1)]; samer@0: end samer@0: samer@0: function [y,yp]=nextm(a,x,yp) samer@0: M=size(x,2); samer@0: y=zeros(size(x)); samer@0: for i=1:M samer@0: [y(:,i),yp]=next1(a,x(:,i),yp); samer@0: end samer@0: end