You are on page 1of 4

23.

Program to design Butterworth low pass filter for given specification

% program to design Butterworth low pass filter for given specification % given specifications are pass band attenuation (ap), % stop band attenuation (as), pass band frequency (fp), stop band % frequency (fs), sampling frequency (F),

clear all; clc; %clear the command window

ap=input('enter the value for a\n'); as=input('enter the value for as\n'); fp=input('enter the value for f\n'); fs=input('enter the value for fs\n'); F=input('enter the value for F\n'); w1=2*fp/F; w2=2*fs/F; [n,wn]=buttord(w1,w2,ap,as); [b,a]=butter(n,wn); w=0:0.01:pi; [h,om]=freqz(b,a,w,'whole'); m=abs(h); an=angle(h); subplot(2,1,1); plot(om/pi,m); title('magnitude response'); xlabel('frequency in hz'); ylabel('gain in db'); grid on; %to subdivide the graphic window %plot the graph %title on the graph %provide label on x-axis %provide label on y-axis %show the grid lines on the plot %Gives Freq response of a filter %computes order of Butterworth filter %design Butterworth filter

subplot(2,1,2); plot(om/pi,an); title('phase response'); xlabel('frequency in hz'); ylabel('phase in radiance'); grid on;

Output: enter the value for a 0.2 enter the value for as 30 enter the value for f 300

enter the value for fs 800 enter the value for F 2000

You might also like