diff m-toolbox/test/test_pzmodel_class.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/test/test_pzmodel_class.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,52 @@
+% Test script for pzmodel class.
+%
+% M Hewitson 03-04-07
+%
+% $Id: test_pzmodel_class.m,v 1.16 2009/02/02 15:20:37 hewitson Exp $
+%
+function test_pzmodel_class()
+  
+  % direct
+  poles = [pz(1,2) pz(40)];
+  zeros = [pz(10,3) pz(100)];
+  pzm   = pzmodel(10, poles, zeros)
+  resp(pzm)
+  
+  % From plist
+  pl  = plist('name', 'test model', 'gain', 10, 'poles', [pz(1,2) pz(40)], 'zeros', [pz(10,3) pz(100)]);
+  pzm = pzmodel(pl)
+  
+  string(pzm)
+  eval(ans)
+  
+  rpl = plist('f1', 0.1, 'f2', 1000, 'nf', 10000);
+  
+  pzm = pzmodel(plist('name', 'pzmodel', ...
+    'gain', 1,         ...
+    'poles', pz(plist('f', 1, 'q', 3)), ...
+    'zeros', pz(3), ...
+    'fs', 2000))
+  a = resp(pzm, rpl)
+  iplot(a)
+  
+  % Make IIR filter
+  
+  pzm = pzmodel(1, pz(1), pz(10))
+  
+  filt = miir(plist('pzmodel', pzm))
+  newfilt = redesign(filt, 2000);
+  
+  filtresp = resp(filt);
+  newfiltresp = resp(newfilt, plist('f', filtresp.data.x));
+  
+  % iplot(filtresp, newfiltresp)
+  plot(filtresp.hist)
+  
+  
+  % Reproduce from history
+  a_out = rebuild(filtresp);
+  
+  iplot(a_out)
+  plot(a_out.hist)
+  
+end