Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.26 KB | None | 0 0
  1. %Extraction of a wavelegth of the signal
  2. [y,Fs]=audioread('s1Insaf.wav');     %read the required audio file
  3. ts=1/Fs;
  4. figure(1);plot (y);title('The full audio signal');
  5.  
  6. y2=y(39000:40000);                %manually extract a part of the audio file
  7. y3=y2/max(y2);
  8. figure(2);plot (y3);title('The extracted Audio signal');
  9.  
  10. x=y2(132:459);                      %select start point and end points of one wavelength
  11. figure(3);plot(x);title('One wavelength');
  12.  
  13.  
  14. %Anlysing the signal
  15.  
  16. Ns=length(x);                       % the no. of samples per wavelength
  17. T=(Ns-1)*ts;
  18. f0=1/T;
  19.  
  20. xa=abs(x);
  21. Xa_avg=(0.5*(xa(1)+xa(Ns))+sum(xa(2:Ns-1)))/(Ns-1);
  22.  
  23.  
  24. x2=x.^2;
  25. X_rms=sqrt((0.5*(x2(1)+x2(Ns))+sum(x2(2:Ns-1)))/(Ns-1));
  26.  
  27. X_peak=max(xa);
  28. X_range=max(x)-min(x);
  29.  
  30. C=X_peak/X_rms;                     % crest factor
  31. PAPR=10*log10(C^2);                 % PAPR
  32. Kf=X_rms/Xa_avg;                    %
  33.  
  34.  
  35. t=0:ts:T;
  36. j=sqrt(-1);
  37. Vh=[];
  38. Ph=[];
  39. for h=1:10
  40. e=x.*exp((-j)*2*pi*h*f0*t');
  41. eint=2*(0.5*(e(1)+e(Ns))+sum(e(2:Ns-1)))/(Ns-1);
  42. Vh=[Vh,abs(eint)];
  43. Ph=[Ph,angle(eint)];
  44. end
  45. Vh=Vh./max(Vh);                     %normalizing the amplitudes.
  46.  
  47. % Representation of phase plot and magnitude plot.
  48. figure(4);stem(Vh);title('Magnitude plot');
  49. figure(5);stem(Ph);title('Phase plot');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement