wiktortokumpel

lista 4-5

Nov 28th, 2022 (edited)
816
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.70 KB | None | 0 0
  1. clear all;
  2. close all;
  3. [x,fs]=audioread('mbi04czep(2).wav');
  4. N=length(x);
  5. czas=[0:1:N-1]/fs;
  6.  
  7. tp=0.15;
  8. tk=0.25;
  9.  
  10. Np=round(tp*fs);
  11.  
  12. Nk=round(tk*fs);
  13. Y=x(Np:Nk);
  14.  
  15. Nt=length(Y);
  16. czasY=[Np:1:Nk]/fs;
  17.  
  18.  
  19. figure(1);
  20. subplot(2,1,1);
  21.  
  22. plot(czas,x);
  23.  
  24. xlabel('czas');
  25. ylabel("Amplituda");
  26. grid on;
  27.  
  28.  
  29. subplot(2,1,2);
  30. plot(czasY,Y);
  31.  
  32. xlabel('czas');
  33. ylabel("Amplituda");
  34. grid on
  35.  
  36. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$44
  37. clear all;
  38. close all;
  39. load("szum_1.mat")
  40. load('szum_2.mat')
  41. %czestotliwosc probkowania sygnalu
  42. fp=250;
  43. %długośc wektorów
  44. N=length(szum_1)
  45.  
  46. t=[0:1:N-1]/fp;
  47.  
  48.  
  49. figure(2)
  50. subplot(2,2,1);
  51. plot(t,szum_1);
  52. xlabel('czas[s]');
  53. ylabel('amplituda');
  54. title('szum 1')
  55.  
  56. subplot(2,2,2)
  57. plot(t,szum_2);
  58. xlabel('czas[s]');
  59. ylabel('amplituda');
  60. title('szum 2')
  61.  
  62. N1=20;
  63. N2=10;
  64.  
  65.  
  66. subplot(2,2,3);
  67. histogram(szum_1,N1);
  68. xlabel('przedział wartości');
  69. ylabel('liczba probek');
  70. title('szum gaussowski');
  71. subplot(2,2,4);
  72. histogram(szum_2,N2);
  73. xlabel('przedział wartości');
  74. ylabel('liczba probek');
  75. title('szum równomierny');
  76.  
  77. figure(1)
  78.  
  79. xp=szum_1(2:2:N);
  80. xn=szum_1(1:2:N);
  81. subplot(2,1,1)
  82. plot(xn,xp,'.')
  83.  
  84. xp2=szum_2(2:2:N);
  85. xn2=szum_2(1:2:N);
  86. subplot(2,1,2)
  87. plot(xn2,xp2,'.')
  88.  
  89. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  90. clear all;
  91. close all;
  92.  
  93. tau=1e-6;
  94. f_start=100;
  95. f_stop=100e6;
  96. fs=250e6;
  97.  
  98. t=[0:1/fs:tau-(1/fs)];
  99. x=chirp(t,f_start,tau-(1/fs),f_stop);
  100. figure(1);
  101. subplot(2,1,1);
  102. plot(t,x);
  103. xlabel('czas')
  104. ylabel('Amplituda');
  105. x_del=radar_echo(x);
  106. Ndel=length(x_del);
  107. t_del=[0:1:Ndel-1];
  108. subplot(2,1,2)
  109. plot(t_del,x_del);
  110.  
  111. kor=xcorr(x,x_del);
  112. figure(2);
  113. plot(kor);
  114.  
  115. [val,idx]=max(kor)
  116. deley=(idx/fs)/2;
  117. v=3e8
  118. dist=v*deley;
  119.  
  120.  
Advertisement
Add Comment
Please, Sign In to add comment