Matt23

zad2

Oct 24th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. N = 32;
  2. n = 0 : 1 : N - 1;
  3. y1 = cos((2 * pi * n / N) + pi / 4);
  4. y2 = 0.5 * cos((4 * pi * n) / N);
  5. y3 = 0.25 * cos((8 * pi * n / N) + pi / 2);
  6. y4 = y1 + y2 + y3;
  7.  
  8. figure
  9. plot(n, y1, n, y2, n, y3);
  10. xlabel('Numer próbki');
  11. ylabel('Wartość');
  12. legend('y1[n] = cos((2 * pi * n / N) + pi / 4)', 'y2[n] = 0.5 * cos((4 * pi * n) / N)', 'y3[n] = 0.25 * cos((8 * pi * n / N) + pi / 2)');
  13.  
  14. y1fourier = 2 * fft(y1) / length(y1);
  15. y2fourier = 2 * fft(y2) / length(y2);
  16. y3fourier = 2 * fft(y3) / length(y3);
  17. y4fourier = 2 * fft(y4) / length(y4);
  18.  
  19. figure
  20. subplot(4,2,1)
  21. stem(abs(y1fourier));
  22.  
  23. subplot(4,2,2)
  24. stem(abs(y2fourier));
  25.  
  26. subplot(4,2,3)
  27. stem(abs(y3fourier));
  28.  
  29. subplot(4,2,4)
  30. stem(abs(y4fourier));
  31.  
  32.  
  33. N = 32 * 8;
  34. n = 0 : 1 : N - 1;
  35. y1 = cos((2 * pi * n / N) + pi / 4);
  36. y2 = 0.5 * cos((4 * pi * n) / N);
  37. y3 = 0.25 * cos((8 * pi * n / N) + pi / 2);
  38. y4 = y1 + y2 + y3;
  39.  
  40.  
  41.  
  42. subplot(4,2,5)
  43. stem(angle(y1fourier));
  44.  
  45. subplot(4,2,6)
  46. stem(angle(y2fourier));
  47.  
  48. subplot(4,2,7)
  49. stem(angle(y3fourier));
  50.  
  51. subplot(4,2,8)
  52. stem(angle(y4fourier));
  53. axis([0 20 -2 2]);
Advertisement
Add Comment
Please, Sign In to add comment