Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. a=1;
  2. m=1;
  3. q=10;
  4. s=wavread('speech');
  5. v=wavread('machine');
  6. y=s+a*v;
  7. tempRsy=XCORR(s,y);
  8. tempRy=XCORR(y);
  9. mitt=ceil(length(tempRy)/2);
  10. Ry=zeros(q,q);
  11. Rsy=zeros(q,1);
  12. j=0;
  13. for g=1:q
  14. for i=1:q
  15. Ry(i,g)=tempRy(mitt+j);
  16. j=j+1;
  17. end
  18. j=j-q-1;
  19. end
  20. f=0;
  21. for h=1:q
  22. Rsy(h,1)=tempRsy(mitt+m+f);
  23. f=f+1;
  24. end
  25. h=Ry\Rsy;
  26. sut=filter(1,h,y);
  27. [g,w]=freqs(1,h);
  28. %-----------------------------------------Fel----------------------------
  29. sum=0;
  30. for i=1:length(s)
  31. sum=sum+(s(i)-sut(i))^2;
  32. end
  33. fel=sum/length(s);
  34.  
  35.  
  36. %------------------------------------------Plottar-----------------------
  37. subplot(3,3,1)
  38. plot(s);
  39. title('s');
  40. xlabel('tid');
  41. ylabel('förstärkning')
  42. subplot(3,3,2)
  43. plot(sut);
  44. title('Sut');
  45. xlabel('tid');
  46. ylabel('förstärkning')
  47. subplot(3,3,3)
  48. plot(y);
  49. title('y');
  50. xlabel('tid');
  51. ylabel('förstärkning')
  52. subplot(3,3,4)
  53. plot(fft(s));
  54. title('s frekvens');
  55. xlabel('frekvens');
  56. ylabel('förstärkning')
  57. subplot(3,3,5)
  58. plot(fft(sut));
  59. title('sut frekvens');
  60. xlabel('frekvens');
  61. ylabel('förstärkning')
  62. subplot(3,3,6)
  63. plot(fft(y));
  64. title('y frekvens');
  65. xlabel('frekvens');
  66. ylabel('förstärkning')
  67. subplot(3,3,7)
  68. plot(w,g);
  69. xlabel('frekvens');
  70. ylabel('förstärkning')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement