Professional Documents
Culture Documents
Digital Filter Design
Digital Filter Design
Digital Filter Design
1/5
Back
This page show simple Digital filter coefficient calculation method
[Hamming ] [FIR Filter] [IIR Filter]
[Hamming ]
= 0.2*pi;
% Passband Frequency
= 0.3*pi;
% Stopband Frequency
= ws - wp;
% Transition Band Frequency
= ceil(6.6*pi/tr_width) + 1 % M = 67(filter order) , w = 6.6*pi / tr_width
% CEIL(X) rounds the elements of X to the nearest integers
towards infinity.
%
%
%
%
n
wc
hd
M-1
= [ 0 : 1 : M-1 ];
= (ws + wp) / 2
= ideal_lp(wc,M);
C:\pec_works\PEC_Office\PEC_2008\Homepage\Naver_Homepage\doc\matlab.htm
2008-11-13 / 4:44
Untitled
2/5
= freqz(b,a,1000,'whole');
= (H(1:1:501))'; w = (w(1:1:501))';
= abs(H);
= 20*log10((mag+eps)/max(mag));
= angle(H);
= unwrap(angle(H));
= grpdelay(b,a,w);
= di
ff(pha);
% grd = [grd(1) grd];
% grd = [0 grd(1:1:500); grd; grd(2:1:501) 0];
% grd = median(grd)*500/pi;
/*************************************************************************************/
% filter length M = 67 , 52dB,
EX2 )
C:\pec_works\PEC_Office\PEC_2008\Homepage\Naver_Homepage\doc\matlab.htm
2008-11-13 / 4:44
Untitled
clf
t
= 0 : 0.001 : 1;
= 1000
y
= sin(2*pi*30*t)+sin(2*pi*80*t)+cos(2*pi*160*t);
subplot(2,1,1), plot(y,'g'); title('time domain');
3/5
% N = (f) = 1/0.001
YY
= fft(y);
%
plot(abs(YY))
ylen
= length(YY);
fs
= 1000;
f1
= 1 : 1 : ylen/2 ;
ff
= ((f1*fs)/(ylen));
magYY
= abs(YY);
figure(1);
ylen2
= round(ylen/2-0.5);
subplot(2,1,2), plot(ff(1:ylen2), magYY(1:ylen2),'k'); title('frequency
domain');
hold on;
fn
= fs/2;
% fs =1000 ;
f1n
= 55/fn;
% fn = 500 , wc = 0.11, lowpass filter
cutoff frequency (30 + 80)/2
for k
= 1 : 5 : 100
[B]
= fir1(k,f1n);
% LPF , k = 0 ~ 100 ,f1n = 0.1100 ;
B:
filter coefficient
[H,wT]
= freqz(B,1,100); % B / 1 , N point
T
= 0.001;
herzt
= wT/(2*pi*T);
figure(1);
subplot(2,1,1), plot(y,'b'); title('time domain , input data display ');
subplot(2,1,2), plot(ff(1:ylen2),magYY(1:ylen2),'k'); title('frequency domain,
fft(frequency analysis');
hold on;
s
= int2str(k);
subplot(2,1,2), plot(herzt,abs(H)* 600,'r');title('in fft plot,Lowpass
fillter'),xlabel('Frequence(Hz)');
ylabel('Amplitude'); text( 250 + k * 8,500,s ); grid; axis([0 1000 -1 650]);
%hold off;
hold on;
pause;
figure(2)
clf;
result = filter(B,1,y);
% y = input data , B = filter coefficient ,
% result = frequency domain filter shape.
plot(result,'c');
plot( result(300:500) );
result
end
C:\pec_works\PEC_Office\PEC_2008\Homepage\Naver_Homepage\doc\matlab.htm
2008-11-13 / 4:44
Untitled
[Hamming] [FIR Filter] ,
4/5
[IIR Filter]
C:\pec_works\PEC_Office\PEC_2008\Homepage\Naver_Homepage\doc\matlab.htm
2008-11-13 / 4:44
Untitled
5/5
C:\pec_works\PEC_Office\PEC_2008\Homepage\Naver_Homepage\doc\matlab.htm
2008-11-13 / 4:44