📄 er_lpfc2.m
字号:
function f = er_lpfc2(N,ris)
% function f = er_lpfc2(N,ris)
% Function to create prototype Chebyshev Type II digital LPF using bilinear
% transformation. Takes filter order in N (even/odd integer) and minimum allowable
% stopband attenuation in RIS (in dB). Normalized cutoff frequency (in rads) occurs where
% the stopband begins and the filter has magnitude response of 10^(-RIS/20). Magnitude
% response is monotonic in the passband and equiripple in the stopband and pole locations
% are the inverse of the Chebyshev Type I filter. Returns transfer function coefficient
% vectors in struct F.
%
% EXAMPLE: >> f = er_lpfc2(6,45), yields 6th-order Type-II Chebyshev
% prototype digital filter with normalized stopband edge at pi/4 with attenuation of 45
% dB in stopband.
%
% Ref: T.W. Parks and C.S. Burrus, Digital Filter Design, New York: John Wiley & Sons, 1987. Chapter 7.
%
% Author: Evan Ruzanski, CU-Boulder, ECEN5632 MATLAB assignment, FA2004
% Filter must be greater than or equal to 2
if (N < 2)
error('Filter order must be >= 2');
end
% Extract parameters from desired stopband ripple
delta = 1/(sqrt(10^(0.1*ris)-1));
mu = asinh(1/delta)/N;
% Generate zeros
if (rem(N,2) ~= 0) % Check and adjust for for even order
m = N - 1;
z = j./cos([1:2:N-2 N+2:2:2*N-1]*pi/(2*N))';
else
m = N;
z = j./cos((1:2:2*N-1)*pi/(2*N))';
end
i = [1:m/2; m:-1:m/2+1]; % Complex pair zeros
z = z(i(:));
% Generate poles
p = exp(j*(pi*(1:2:2*N-1)/(2*N) + pi/2))';
p = sinh(mu)*real(p) + j*cosh(mu)*imag(p);
p = 1./p;
% Generate gain constant
k = real(prod(-p)/prod(-z));
% Do zero/pole bilinear transformation, T = 2
fs = 1;
pd = (1+p/fs)./(1-p/fs); % Flip for z^(-1)
zd = (1+z/fs)./(1-z/fs);
kd = (k*prod(fs-z)./prod(fs-p));
zd = [zd; -ones(length(pd)-length(zd),1)]; % Add extra zeros at -1
numd = real(kd*poly(zd));
dend = real(poly(pd));
% Pack output parameters into struct
f = struct('tf_complete',{numd,dend});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -