Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. clear all;
  2. N=12000;
  3. fp=10000;
  4.  
  5. t=0:1/fp:(N-1)/fp;
  6. x1= 4*chirp(t,100,t(end),450);
  7. x2= 2*chirp(t,150,t(end),600);
  8. x3= 4*sin(2*pi*t*350);
  9. x4= 5*rand(1,N);
  10. x=x1+x2+x3+x4;
  11.  
  12. figure(1);
  13. %oczyt
  14. subplot(221);
  15. plot(t,x);
  16. xlabel('czas[s]');
  17. ylabel('x(t)');
  18. title('sygnal');
  19.  
  20. %modul widma
  21. Nf=2^14;
  22. Nf21=Nf/2+1;
  23. f=linspace(0,fp/2,Nf21);
  24. v=fft(x,Nf);
  25. w=abs(v);
  26. subplot(222);
  27. plot(f,w(1:Nf21));
  28. xlabel('czest[Hz]');
  29. ylabel('|x(f)|');
  30. title('modul widma sygnalu');
  31.  
  32. %decymacja
  33. dr=floor(fp/(2*600));
  34. y=decimate(x,dr);
  35. fpy=fp/dr;
  36. Ny=length(y);
  37. ty=0:1/fpy:(Ny-1)/fpy;
  38. subplot(223);
  39. plot(ty,y);
  40. xlabel('czas[s]');
  41. ylabel('y(t)');
  42. title('sygnal po decymacji');
  43.  
  44. %modul widma decymacji
  45. Nfy=2^11;
  46. Nf21y=Nfy/2+1;
  47. fy=linspace(0,fpy/2,Nf21y);
  48. vy=fft(y,Nfy);
  49. wy=abs(vy);
  50. subplot(224);
  51. plot(fy,wy(1:Nf21y));
  52. xlabel('czest[Hz]');
  53. ylabel('|y(f)|');
  54. title('modul widma decymacji');
  55.  
  56. figure(2);
  57. %odp imp filtru
  58. M=301;
  59. h=fir1(M-1,200/(fpy/2));
  60. th=0:1/fpy:(M-1)/fpy;
  61. subplot(221);
  62. plot(th,h);
  63. xlabel('czas[s]');
  64. ylabel('h(t)');
  65. title('odp imp filtru');
  66. %modul widma odp im filtru
  67. Nfh=2^nextpow2(M);
  68. Nf21h=Nfh/2+1;
  69. fh=linspace(0,fpy/2,Nf21h);
  70. vh=fft(h,Nfh);
  71. wh=abs(vh);
  72. subplot(222);
  73. plot(fh,wh(1:Nf21h));
  74. xlabel('czest[Hz]');
  75. ylabel('|h(f)|');
  76. title('modul widma odp imp filtru');
  77.  
  78. %filtracja
  79. z=filter(h,1,y);
  80. subplot(223);
  81. plot(ty,z);
  82. xlabel('czas[s]');
  83. ylabel('z(t)');
  84.  
  85. %modul widma sygnalu po filtracji
  86. vhy=fft(z,Nfy);
  87. why=abs(vhy);
  88. subplot(224);
  89. plot(fy,why(1:Nf21y));
  90. xlabel('czest[Hz]');
  91. ylabel('|z(f)|');
  92. title('modul widma sygnalu po filtracji');
  93.  
  94. figure(3);
  95.  
  96. kmax=20;
  97. rx=xcorr(z,z,kmax);
  98. tr=-kmax/fpy:1/fpy:kmax/fpy;
  99. subplot(121);
  100. plot(tr,rx);
  101.  
  102.  
  103. nbis=35;
  104. subplot(122);
  105. hist(z);
  106.  
  107.  
  108.  
  109. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement