CP2IIR Return a,b IIR filter coefficients for a complex pole designed using the bilinear transform. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: CP2IIR Return a,b IIR filter coefficients for a complex pole designed using the bilinear transform. CALL: [a,b] = cp2iir(p, fs) REMARK: This is just a helper function. This function should only be called from class functions. INPUT: p - pole object fs - the sample rate for the filter VERSION: $Id: cp2iir.html,v 1.14 2008/03/31 10:27:38 hewitson Exp $ HISTORY: 03-04-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function [a,b] = cp2iir(p, fs) 0002 % CP2IIR Return a,b IIR filter coefficients for a complex pole designed using the bilinear transform. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: CP2IIR Return a,b IIR filter coefficients for a complex pole 0007 % designed using the bilinear transform. 0008 % 0009 % CALL: [a,b] = cp2iir(p, fs) 0010 % 0011 % REMARK: This is just a helper function. This function should only be 0012 % called from class functions. 0013 % 0014 % INPUT: p - pole object 0015 % fs - the sample rate for the filter 0016 % 0017 % VERSION: $Id: cp2iir.html,v 1.14 2008/03/31 10:27:38 hewitson Exp $ 0018 % 0019 % HISTORY: 03-04-2007 M Hewitson 0020 % Creation 0021 % 0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0023 0024 VERSION = '$Id: cp2iir.html,v 1.14 2008/03/31 10:27:38 hewitson Exp $'; 0025 CATEGORY = 'Internal'; 0026 0027 %%%%% 'Params' && 'Version' Call %%%%% 0028 if nargin == 2 0029 if isa(p, 'pole') && ischar(fs) 0030 in = fs; 0031 if strcmp(in, 'Params') 0032 a = plist(); 0033 return 0034 elseif strcmp(in, 'Version') 0035 a = VERSION; 0036 return 0037 elseif strcmp(in, 'Category') 0038 a = CATEGORY; 0039 return 0040 end 0041 end 0042 end 0043 0044 f0 = get(p, 'f'); 0045 q = get(p, 'q'); 0046 0047 w0 = f0*2*pi; 0048 w02 = w0^2; 0049 0050 k = (q*w02 + 4*q*fs*fs + 2*w0*fs) / (q*w02); 0051 b(1) = 1; 0052 b(2) = (2*w02-8*fs*fs) / (k*w02); 0053 b(3) = (q*w02 + 4*q*fs*fs - 2*w0*fs) / (k*q*w02); 0054 0055 a(1) = 1/k; 0056 a(2) = -2/k; 0057 a(3) = -1/k; 0058 a = a*-2; 0059 0060 % END