TOMIIR converts a pzmodel to an IIR filter using a bilinear transform. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: TOMIIR converts a pzmodel to an IIR filter using a bilinear transform. CALL: f = tomiir(pzm, fs); % construct for this sample frequency fs f = tomiir(pzm, pl); % construct from plist PARAMETERS: 'fs' - sample frequency VERSION: $Id: tomiir.html,v 1.14 2008/03/31 10:27:37 hewitson Exp $ HISTORY: 03-04-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function f = tomiir(varargin) 0002 % TOMIIR converts a pzmodel to an IIR filter using a bilinear transform. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: TOMIIR converts a pzmodel to an IIR filter using a bilinear 0007 % transform. 0008 % 0009 % CALL: f = tomiir(pzm, fs); % construct for this sample frequency fs 0010 % f = tomiir(pzm, pl); % construct from plist 0011 % 0012 % PARAMETERS: 'fs' - sample frequency 0013 % 0014 % VERSION: $Id: tomiir.html,v 1.14 2008/03/31 10:27:37 hewitson Exp $ 0015 % 0016 % HISTORY: 03-04-2007 M Hewitson 0017 % Creation 0018 % 0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0020 0021 VERSION = '$Id: tomiir.html,v 1.14 2008/03/31 10:27:37 hewitson Exp $'; 0022 CATEGORY = 'Operator'; 0023 0024 % Check if this is a call for parameters 0025 if nargin == 2 0026 if isa(varargin{1}, 'pzmodel') && ischar(varargin{2}) 0027 in = char(varargin{2}); 0028 if strcmp(in, 'Params') 0029 f = plist; 0030 return 0031 elseif strcmp(in, 'Version') 0032 f = VERSION; 0033 return 0034 elseif strcmp(in, 'Category') 0035 f = CATEGORY; 0036 return 0037 end 0038 end 0039 end 0040 0041 pzm = varargin{1}; 0042 if ~isa(pzm, 'pzmodel') 0043 error('### first argument should be a pzmodel.'); 0044 end 0045 0046 if nargin < 1 0047 error('### incorrect number of inputs.'); 0048 end 0049 0050 % Get fs 0051 if nargin == 1 0052 warning('!!! Using default sample rate of 1Hz to design filter.'); 0053 fs = 1; 0054 else 0055 if isa(varargin{2}, 'plist') 0056 pl = varargin{2}; 0057 fs = find(pl, 'fs'); 0058 if isempty(fs) 0059 error('### unknown parameter list.'); 0060 end 0061 else 0062 fs = varargin{2}; 0063 end 0064 end 0065 0066 % get a and b coefficients 0067 [a,b] = pzm2ab(pzm, fs); 0068 0069 % make MIIR filter 0070 f = miir(a,b,fs); 0071 0072 0073 % END