Professional Documents
Culture Documents
1. clear all
2. alphap=2; %passband attenuation in dB
3. alphas=20; %stopband attenuation in dB
4. wp=[.2*pi,.4*pi]; % passband freq. in radians
5. ws=[.1*pi,.5*pi]; % stopband freq. in radians
6. %to find cutoff freq. and order of the filter
7. [n,wn]=buttord(wp/pi,ws/pi,alphap,alphas); %syatem function of the filter
8.
9.
10. [b,a]=butter(n,wn);
11. w=0:.01:pi;
12. [h,ph]=freqz(b,a,w);
13. m=20*log10(abs(h));
14. an=angle(h);
15. subplot(2,1,1);plot(ph/pi,m);grid;
16. ylabel('Gain in dB');
17. xlabel('NORMALISED FREQUENCY');
18. subplot(2,1,2);plot(ph/pi,an);grid
19. ylabel('phase in radians');
20. xlabel('noramlised frequency');
Band Stop Filter
1. clear all
2. alphap=2; %passband attenuation in dB
3. alphas=20; %stopband attenuation in dB
4. wp=[.2*pi,.4*pi]; % passband freq. in radians
5. ws=[.1*pi,.5*pi]; % stopband freq. in radians
6. %to find cutoff freq. and order of the filter
7. [n,wn]=buttord(wp/pi,ws/pi,alphap,alphas); %syatem function of the filter
8. [b,a]=butter(n,wn,'STOP');
9. w=0:.01:pi;
10.
11.
12. [h,ph]=freqz(b,a,w);
13. m=20*log(abs(h));
14. an=angle(h);
15. subplot(2,1,1);plot(ph/pi,m);grid;
16. ylabel('Gain in dB');
17. xlabel('NORMALISED FREQUENCY')
18. subplot(2,1,2);plot(ph/pi,an);grid
19. ylabel('phase in radians');
20. xlabel('noramlised frequency')