Frequency response of digital filter

조회 수: 14 (최근 30일)
Joshua Brown
Joshua Brown 2019년 11월 5일
답변: Zubair Zebary 2022년 12월 5일
I need to calculate the frequency response of a butter worth low pass digital filter.
I calculated the transfer function of a butterworth low pass filter to be:
Y(s)/X(s) =39.476/(s^2+8.886 s+39.476)
I then used bilinear transform to obtain the 'z' transfer funtion:
Y(z)/X(z) =(0.0198(z^2+2z+1))/(z^2-1.564 z+0.644)
I now need to use matlab to obtain the frequency response of this digital filter in the digital and analgue domain. then check if they match around the break/cutoff frequency.
I assume I need to use 'Freqs' and 'Freqz' but I am not sure if i am getting the correct results. Could somone assist? (my current code below)
a=[1,1.564,0.644]
b=[0.0198,0.0396,0.0198]
w=logspace(-2,3)
sys=tf(b,a)
h = freqs(b,a,w );
mag = mag2db(abs(h ));
phase = angle(h );
phasedeg = phase*180/pi ;
subplot(2,1,1), semilogx(w,mag), grid on
xlabel 'Frequency (rad/s)', ylabel 'Magnitude (dB)'
subplot(2,1,2), semilogx(w,phasedeg), grid on
xlabel 'Frequency (rad/s)', ylabel 'Phase (degrees )'
pause
[h,w] = freqz(b,a,'whole',2001);
mag = mag2db(abs(h ));
phase = angle(h );
phasedeg = phase*180/pi ;
subplot(2,1,1), semilogx(w,mag), grid on
xlabel 'Frequency (rad/s)', ylabel 'Magnitude (dB)'
subplot(2,1,2), semilogx(w,phasedeg), grid on
xlabel 'Frequency (rad/s)', ylabel 'Phase (degrees )'

답변 (2개)

Mahesh Taparia
Mahesh Taparia 2019년 11월 22일
Hi Joshua
In your code, you are using same transfer function for ‘s’ and ‘z’ domain. You specified Y(s)/X(s) which you did not used. It should be as following
a=[36.476];
b=[1,8.886,39.476];
sys=tf(a,b);
To do bilinear transformation you can use MATLAB in built function ‘bilinear’ as follows:
[num,den]=bilinear(a,b,Fs);
where Fs=sampling rate. For more information of bilinear function, you can refer to the documentation here.
Now to analyze the frequency response of filter in analog and in digital domain you can use ‘freqs and ‘freqzcommand respectively (like you did in your code).
Moreover, you can also use fvtool function to find frequency response of a digital filter. For more information on ‘fvtoolyou can refer to the documentation here

Zubair Zebary
Zubair Zebary 2022년 12월 5일
If 𝑥(𝑛) = 0.5 𝛿(𝑛) + 𝛿(𝑛 − 1) + 0.5 𝛿(𝑛 − 2). Plot the magnitude and angle of 𝐻(𝑒 𝑗𝑊) in the period of [0 2π].

카테고리

Help CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by