Hello, I'm new to Matlab. I am trying to plot the frequency and phase response of analog filters like butterworth, chebyshev ect. Since I cant make the output of freqs appear in the same plot I tried ploting them manually but my output is not the same as freqs and I dont know why. Here is the code:
%Filter Butterworth
[zb,pb,kb] = butter(3,1,'s');[bb,ab] = zp2tf(zb,pb,kb);[h{1},w{1}] = freqs(bb,ab,1000);figurefreqs(bb,ab,1000);%Filter Chebyshev
[z1,p1,k1] = cheby1(3,1,1,'s');[b1,a1] = zp2tf(z1,p1,k1);[h{2},w{2}] = freqs(b1,a1,1000);figurefreqs(b1,a1,1000);%Filter Eliptic
[ze,pe,ke] = ellip(3,1,30,1,'s');[be,ae] = zp2tf(ze,pe,ke);[h{3},w{3}] = freqs(be,ae,1000);figurefreqs(be,ae,1000);%Filter Bessel
[zs,ps,ks] = besself(3,1);[bs,as] = zp2tf(zs,ps,ks);[h{4},w{4}] = freqs(bs,as,1000);figurefreqs(bs,as,1000);figuresubplot(2,1,1)hold onfor k = 1:4 plot(w{k},20*log10(abs(h{k})))endhold offgridaxis([0.1 10 -40 1]);xlabel('Frequency (rad/s)');ylabel('Attenuation (dB)');legend('Butterworth','Chebyshev','Elliptik','Bessel');subplot(2,1,2)hold onfor k = 1:4 plot(w{k},angle(h{k}))endhold offgridxlabel('Frequency (rad/s)');ylabel('Phase');legend('Butterworth','Chebyshev','Elliptik','Bessel');
For startes the magnitude of freqs is 1 but when I plot it drops to 0. What am I doing wrong?
Best Answer