Bandstop starts at 2.7 dB instead of 0 dB. Why? Demo Code from a Matlab Book

4 vues (au cours des 30 derniers jours)
Wolf Zimmermann
Wolf Zimmermann le 29 Juil 2020
Commenté : Shae Morgan le 14 Août 2020
hello guys, i have this demo code from a matlab lecture which first makes a LP-butterworth Filter and then makes a LP->BS Transformation. I don't get why the plot in the Bandstop starts around 2.7 dB or something and not at 0 dB. in this book is also a LP->BP Transformation with the formulas i need to change in the code and this is waht i need. but also in this transformation, the BP starts at its cutoff frequencies and raises to 150 dB for example (with my values). And i really don't get, why and on which parametres it depends, that the "limit" is not at 0 dB.
This is the Code for the Notch Filter which is working, but also boosts frequencies until the cutoff frequencies are reached:
% Auxillary computation for analog BW lowpass
% dsp_iirdes_1 * mw * 2017
%% Analog Butterworth LP
dD = .1; dS = .2;
fD = 2.2; fS = 4.8; % in kH
epsilon = sqrt(1/(1-dD)^2 - 1);
lambda = sqrt(1/dS^2 - 1);
N = ceil((log(lambda/epsilon)/log(fS/fD)));
f3dB = fD/epsilon^(1/N);
%% Poles in s domaine (normalized)
ps = []; a = 1i*pi/(2*N);
for k=1:N
ps = [ps exp(a*(2*k+N-1))];
end
%% Bilinear transform (normalized)
Omega = pi/5; % target for 3dB normalized radian frequency
alpha = tan(Omega/2);
pz = (1+alpha*ps)./(1-alpha*ps);
%% Filter coefficients
a = poly(pz); b = poly([-1 -1 -1]);
%% Pol-zero diagram, H(1)=1
% IIR LP filter to IIR BS filter
% dsp_iirdsg_2.m * mw * 2017
%% Prototype low-pass (Butterworth)
bLP = [3 10 10 3];
aLP = [1 -1.76004 1.18289 -0.27806];
wcLP = .2*pi; % 3dB corner frequency (design)
pLP = roots(aLP); zLP = roots(bLP); % poles and zeros
fvtool(bLP*sum(aLP)/sum(bLP),aLP) % filter viewer
%% LP-BS-Transform
wL = .4*pi; wU = .5*pi;
alpha = cos((wU+wL)/2)/cos((wU-wL)/2);
beta = tan((wU-wL)/2)*tan(wcLP/2);
for k = 1:length(zLP)
m = 2*(k-1) + 1;
P = 2*alpha*(1-pLP(k))/((1-beta)*pLP(k)-beta-1);
Q = ((1+beta)*pLP(k) + beta - 1)/((1-beta)*pLP(k)-beta-1);
p5(m) = -P/2 + sqrt(P^2-4*Q)/2;
p5(m+1) = -P/2 - sqrt(P^2-4*Q)/2;
P = 2*alpha*(1-zLP(k))/((1-beta)*zLP(k)-beta-1);
Q = ((1+beta)*zLP(k) + beta - 1)/((1-beta)*zLP(k)-beta-1);
z5(m) = -P/2 + sqrt(P^2-4*Q)/2;
z5(m+1) = -P/2 - sqrt(P^2-4*Q)/2;
end
a5 = poly(p5); b5 = poly(z5);
fvtool(b5,a5) % filter viewer

Réponses (1)

Shae Morgan
Shae Morgan le 10 Août 2020
Modifié(e) : Shae Morgan le 10 Août 2020
If a filter is a perfect rectangular filter, then filtering begins at the cutoff frequency and goes to the desired attenuation/gain.
In other filters, the cutoff frequency is commonly defined as the "half-power" point in the function. That is to say, when the function attenuates by half of the initial power (~3 dB = 10*log10(1/2)) that is where the cutoff frequency is.
This is my guess as to why there is a cuttoff around 3 dB. As you increase the filter attenuation rate (filter slope) then that 3 dB down point will get closer and closer to your desired cutoff frequency

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by