Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fs = 8000; %frequency sampling
- t = 0:1/fs:1; % time range
- x = 4*cos(2*pi*400*t)+4*cos(2*pi*900*t+0.5*pi)+5*cos(2*pi*400*t+0.25*pi); %signal x
- %H(z) = Y(z)/X(z) = (1 + 3 2*-2)/ (1 - 1/3 z*-1)
- b = [0.0201 0.0000 -0.0402 0.0000 0.0201 ]
- a = [1.0000 -2.1192 2.6952 -1.6924 0.6414 ]
- y = filter(b,a,x); % filtering
- %fft sinyal awal
- Ak1=abs(fft(y))/length(x);
- k1=0:1:length(x)-1;
- f1=k1*fs/length(x);
- %fft sinyal setelah filter
- Ak2=abs(fft(y))/length(y);
- k2=0:1:length(y)-1;
- f2=k2*fs/length(y);
- %plot
- figure(1);
- subplot(2,1,1)
- plot(f1,Ak1)
- subplot (2,1,2)
- plot(f2,Ak2)
- figure(2);
- freqz(b,a,512,fs); %frekuensi respon filter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement