ellip_3db_bp.m

来自「编写一个函数」· M 代码 · 共 30 行

M
30
字号
function [b,a] = ellip_3db_bp(N,Fc,Apass,Astop)

% ELLIP3DB Design a lowpass elliptic filter for a given 3 dB point.
%   Inputs:
%       N     - Filter order
%       Fc :[wc1 wc2]   - 3 dB cutoff frequency (0 to 1)
%       Apass - Passband attenuation (dB)
%       Astop - Stopband attenuation (dB)

M=N/2;

% Design an elliptic filter for any fp
fp = 0.5; % To keep things simple, we make fp equal to Fc

% Design prototype filter
[btemp,atemp] = ellip(M,Apass,Astop,fp);

% Find 3 db point
[H,w]=freqz(btemp,atemp,1024);
indx = max(find(abs(H).^2 >.5));
% Refine search 
[H2,w2]=freqz(btemp,atemp,linspace(w(indx),w(indx+1),1000)');
indx2 = max(find(abs(H2).^2 >.5));
f3db = w2(indx2)/pi;

% Apply frequency transformation to obtain final filter
[b,a] = iirlp2bp(btemp,atemp,f3db,Fc)
fvtool(b,a);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?