Advertisement
matikap2

nad i podprobkowanie

May 25th, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.71 KB | None | 0 0
  1. clc; clear; close all;
  2.  
  3. f1= 8;
  4. N=4;
  5. M=2;
  6. t1=-0.5:1/(f1*16):0.5;
  7.  
  8. sin1= sin(2*pi*f1.*t1),
  9.  
  10. sin2=zeros(1,length(sin1)*N),
  11. sin2(1:N:length(sin2))=sin1;
  12.  
  13. sin3=sin1(1:M:length(sin1));
  14.  
  15. t1= linspace(-0.5,0.5,length(sin1))
  16.  
  17. t2= linspace(-0.5,0.5,length(sin2))
  18.  
  19. t3= linspace(-0.5,0.5,length(sin3))
  20.  
  21. B1= fir1(20,1/(2*N));
  22. B2= fir1(20,1/(2*M));
  23.  
  24. sinf2=filter(B1,1,sin2);
  25. sinf3=filter(B2,1,sin3);
  26.  
  27. dft1=fft(sin1),
  28. dft2=fft(sinf2),
  29. dft3=fft(sinf3),
  30.  
  31. figure(1);
  32. subplot(2,1,1)
  33. plot(t1, sin1,'.-'); hold on; plot(t2,sinf2,'.');
  34. subplot(2,1,2)
  35. plot(t1, sin1,'.-'); hold on; plot(t3,sinf3,'o');
  36.  
  37. figure(2);
  38. subplot(3,1,1)
  39. plot(abs(dft1));
  40. subplot(3,1,2)
  41. plot(abs(dft2));
  42. subplot(3,1,3)
  43. plot(abs(dft3));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement