diff m-toolbox/classes/+utils/@math/mtxiirresp2.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@math/mtxiirresp2.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,31 @@
+% MTXIIRRESP calculate iir resp by matrix product
+%
+% A contains numerators coefficients (a row for each filter)
+% A contains denominators coefficients (a row for each filter)
+%
+% NOTE: A and B should have the same size, zero pad if necessary
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function rsp = mtxiirresp2(A,B,freq,fs)
+  T = 1/fs;
+  
+  % build Z matrix
+  Z = ones(size(A,2),numel(freq));
+  zz = exp(-2.*pi.*1i.*T.*freq);
+  for jj=2:size(Z,1)
+    Z(jj,:) = zz.^(jj-1);
+  end
+  
+  % get numerator and denominator
+  num = A*Z;
+  den = B*Z;
+  % get response
+  rspm = num./den;
+  if size(A,1)>1
+    rsp = sum(rspm,1);
+  else
+    rsp = rspm;
+  end
+
+
+end
\ No newline at end of file