view m-toolbox/test/test_pzmodel_class.m @ 11:9174aadb93a5 database-connection-manager

Add LTPDA Repository utility functions into utils.repository
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% 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