Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. clear all;
  2. [x,fpx] = audioread('mbi04czap.wav');
  3. Nx=length(x);
  4. tx=0:1/fpx:(Nx-1)/fpx;
  5. subplot(2,2,1);
  6. plot(tx,x);
  7. xlabel('czas[s]');
  8. ylabel('x(t)');
  9. title('sygnal org');
  10.  
  11. Nfx = 2^11;
  12. Nfx21=Nfx/2+1;
  13. v=fft(x,Nfx);
  14. wx=abs(v);
  15. fx=linspace(0,fpx/2,Nfx21);
  16. subplot(2,2,2);
  17. plot(fx, wx(1:Nfx21));
  18. xlabel('czest [Hz]');
  19. ylabel('|X(f)|');
  20. title('modul widma sygnalu org');
  21.  
  22. dr=3;
  23. Ny=floor(Nx/dr);
  24.  
  25. %pierwszy sposob
  26. %for i=1:Ny
  27. % y(i)=x((i-1)*dr+1);
  28. %end
  29.  
  30. %drugi sposob
  31. y=decimate(x,dr);
  32. Ny=length(y);
  33.  
  34.  
  35. fpy=fpx/dr;
  36. ty=0:1/fpy:(Ny-1)/fpy;
  37. subplot(2,2,3);
  38. plot(ty,y);
  39. xlabel('czas[s]');
  40. ylabel('y(t)');
  41. title('sygnal po decymacji');
  42.  
  43. Nfy = 2^14;
  44. Nfy21=Nfy/2+1;
  45. v=fft(y,Nfy);
  46. wy=abs(v);
  47. fy=linspace(0,fpy/2,Nfy21);
  48. subplot(2,2,4);
  49. plot(fy, wy(1:Nfy21));
  50. xlabel('czest [Hz]');
  51. ylabel('|Y(f)|');
  52. title('modul widma sygnalu po decymacji');
  53.  
  54. _____________________________________________
  55. clear all;
  56.  
  57. N=4000;
  58. fp=10000;
  59. t=0:1/fp:(N-1)/fp;
  60. x= sin(2*pi*t*740)+sin(2*pi*370*t);
  61. subplot(3,3,1);
  62. plot(t,x);
  63. xlabel('czas [s]');
  64. ylabel('x(t)');
  65. title('sinusoida');
  66.  
  67. kmax=100;
  68. rx=xcorr(x,x,kmax);
  69. tr=-kmax/fp:1/fp:kmax/fp;
  70. subplot(3,3,2);
  71. plot(tr,rx);
  72. xlabel('przesuniecie [s]');
  73. ylabel('autokorelacja x(t)');
  74.  
  75. y=randn(1,N);
  76. subplot(3,3,4);
  77. plot(t,y);
  78. xlabel('czas [s]');
  79. ylabel('y(t)');
  80. title('szum naturalny');
  81.  
  82. ry=xcorr(y,y,kmax);
  83. subplot(3,3,5);
  84. plot(tr,ry);
  85. xlabel('przesuniecie [s]');
  86. ylabel('autokorelacja y(t)');
  87.  
  88.  
  89. z=rand(1,N);
  90. subplot(3,3,7);
  91. plot(t,z);
  92. xlabel('czas [s]');
  93. ylabel('z(t)');
  94. title('szum jednorodny');
  95.  
  96. rz=xcorr(z,z,kmax);
  97. subplot(3,3,8);
  98. plot(tr,rz);
  99. xlabel('przesuniecie [s]');
  100. ylabel('autokorelacja z(t)');
  101.  
  102. nbins=21;
  103. subplot(3,3,3);
  104. hist(x,nbins);
  105. xlabel('wart. probki ');
  106. ylabel('ilosc probek');
  107. title('histogram x(t)');
  108.  
  109.  
  110. subplot(3,3,6);
  111. hist(y,nbins);
  112. xlabel('wart. probki ');
  113. ylabel('ilosc probek');
  114. title('histogram y(t)');
  115.  
  116. subplot(3,3,9);
  117. hist(z,nbins);
  118. xlabel('wart. probki ');
  119. ylabel('ilosc probek');
  120. title('histogram z(t)');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement