Advertisement
Guest User

PS 3.2 2

a guest
Nov 18th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.71 KB | None | 0 0
  1. N = 16;
  2. n = 0:N-1;
  3.  
  4. close all;
  5. y1 = cos(2*pi*n/N+pi/4);
  6. y2 = 0.5*cos(4*pi*n/N);
  7. y3 = 0.25*cos(8*pi*n/N+pi/2);
  8.  
  9. figure;
  10. hold on;
  11. plot(y1,'red');
  12. plot(y2,'blue');
  13. plot(y3,'black');
  14. xlabel('Numer próbki');
  15. ylabel('Wartość');
  16. 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')
  17.  
  18.  
  19. figure;
  20. subplot(2,2,1);
  21. x1=2*fft(y1)/N;
  22. stem(abs(x1));
  23. axis([0 16 0 1]);
  24. xlabel('Numer pasma częstotliwościowego');
  25. ylabel('Magnituda');
  26. title('y1[n]=cos(2*pi*n/N+pi/4)');
  27.  
  28. subplot(2,2,2);
  29. x2=2*fft(y2)/N;
  30. stem(abs(x2));
  31. axis([0 16 0 1]);
  32. xlabel('Numer pasma częstotliwościowego');
  33. ylabel('Magnituda');
  34. title('y2[n]=0.5*cos(4*pi*n/N)');
  35.  
  36. subplot(2,2,3);
  37. x3=2*fft(y3)/N;
  38. stem(abs(x3));
  39. axis([0 16 0 1]);
  40. xlabel('Numer pasma częstotliwościowego');
  41. ylabel('Magnituda');
  42. title('y3[n]=0.5*cos(4*pi*n/N)');
  43.  
  44. y4=y1+y2+y3;
  45. subplot(2,2,4);
  46. x4=2*fft(y4)/N;
  47. stem(abs(x4));
  48. axis([0 16 0 1]);
  49. xlabel('Numer pasma częstotliwościowego');
  50. ylabel('Magnituda');
  51. title('y1+y2+y3');
  52.  
  53. figure;
  54. z1=angle(x1)/pi;
  55. subplot(3,2,1);
  56. stem(z1);
  57. axis([0 16 -1 1]);
  58. xlabel('Numer pasma częstotliwościowego');
  59. ylabel('Faza[pi x rad]');
  60. title('y1[n]=cos(2*pi*n/N+pi/4)');
  61.  
  62. z2=angle(x2)/pi;
  63. subplot(3,2,2);
  64. stem(z2);
  65. axis([0 16 -1 1]);
  66. xlabel('Numer pasma częstotliwościowego');
  67. ylabel('Faza[pi x rad]');
  68. title('y2[n]=0.5*cos(4*pi*n/N)');
  69.  
  70. z3=angle(x3)/pi;
  71. subplot(3,2,3);
  72. stem(z3);
  73. axis([0 16 -1 1]);
  74. xlabel('Numer pasma częstotliwościowego');
  75. ylabel('Faza[pi x rad]');
  76. title('y3[n]=0.5*cos(4*pi*n/N)');
  77.  
  78.  
  79. z4=angle(x4)/pi;
  80. subplot(3,2,4);
  81. stem(z4);
  82. axis([0 16 -1 1]);
  83. xlabel('Numer pasma częstotliwościowego');
  84. ylabel('Faza[pi x rad]');
  85. title('y1+y2+y3');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement