MATLAB CODE TO DESIGN A BUTTERWORTH LOWPASS FILTER

CODE:


clear all
alpha=.4;  %passband attenuation in dB
alphas=30; %stopband attenuation in dB
fp=400; %passband freq. in hz
fs=800; %stopband freq. in hz
F=2000; %sampling freq. in hz
omp=2*fp/F;oms=2*fs/F; % To find cutoff freq. and order of the filter
[n,wn]=buttord(omp,oms,alpha,alphas) %syatem function of the filter
[b,a]=butter(n,wn)
w=0:.01:pi;
[h,om]=freqz(b,a,w,'whole');
m=abs(h);
an=angle(h);
subplot(2,1,1);plot(om/pi,20*log(m));grid;
ylabel('gain in dB');
Xlabel('NORMALISED FREQUENCY')
subplot(2,1,2);plot(om/pi,an);grid
ylabel('phase in radians')
xlabel('noramlised frequency')


OUTPUT:



n =4
wn =0.5821
b =  0.1518    0.6073    0.9109    0.6073    0.1518
a =1.0000    0.6418    0.6165    0.1449    0.0259
 


0 comments:

Post a Comment