MATLAB CODE TO DESIGN A BUTTERWORTH HIGHPASS FILTER

CODE:
clear all
alphap=.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,alphap,alphas) %syatem function of the filter
[b,a]=butter(n,wn,'high')
w=0:.01:pi;
[h,om]=freqz(b,a,w);
m=20*log(abs(h));
an=angle(h);
subplot(2,1,1);plot(om/pi,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.0535   -0.2139    0.3209   -0.2139    0.0535
a =  1.0000    0.6418    0.6165    0.1449    0.0259




0 comments:

Post a Comment