Frequency response of digital filter
13 次查看(过去 30 天)
显示 更早的评论
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 )'
0 个评论
回答(2 个)
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 ‘freqz’ command 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 ‘fvtool’ you can refer to the documentation here
0 个评论
Zubair Zebary
2022-12-5
If 𝑥(𝑛) = 0.5 𝛿(𝑛) + 𝛿(𝑛 − 1) + 0.5 𝛿(𝑛 − 2). Plot the magnitude and angle of 𝐻(𝑒 𝑗𝑊) in the period of [0 2π].
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Filter Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!