Advertisement
Guest User

bagas ganteng

a guest
Sep 19th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. fs = 8000; %frequency sampling
  2. t = 0:1/fs:1; % time range
  3. 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
  4. %H(z) = Y(z)/X(z) = (1 + 3 2*-2)/ (1 - 1/3 z*-1)
  5. b = [0.0201 0.0000 -0.0402 0.0000 0.0201 ]
  6. a = [1.0000 -2.1192 2.6952 -1.6924 0.6414 ]
  7.  
  8. y = filter(b,a,x); % filtering
  9. %fft sinyal awal
  10. Ak1=abs(fft(y))/length(x);
  11. k1=0:1:length(x)-1;
  12. f1=k1*fs/length(x);
  13. %fft sinyal setelah filter
  14. Ak2=abs(fft(y))/length(y);
  15. k2=0:1:length(y)-1;
  16. f2=k2*fs/length(y);
  17. %plot
  18. figure(1);
  19. subplot(2,1,1)
  20. plot(f1,Ak1)
  21. subplot (2,1,2)
  22. plot(f2,Ak2)
  23. figure(2);
  24. freqz(b,a,512,fs); %frekuensi respon filter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement