Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. %%task3
  2. clc
  3. close all
  4. clear all
  5. load('task3.mat')
  6. %% Values
  7.  
  8. N=2048;
  9. t1=1/fs;
  10. x1=x;
  11. x2=x(1:2048);
  12. df1=fs/length(x1);
  13. df2=fs/N;
  14. f1=0:df1:fs-df1;
  15. f2=0:fs/N:fs-fs/N;
  16. %% From newton signal to transient spectre
  17. % N=16384
  18. xf1=fft(x1);
  19. xfpower1=abs(xf1);
  20. xfpower1=xfpower1.^2;
  21. Scale1=2*(t1.^2);
  22. xfenergy1=xfpower1*Scale1; %Esd
  23. xfenergy1(1)=xfenergy1(1)/2; % as the factor two shouldnt be added for gxx(0) as stated in the lecture notes because of properly scaled DC value
  24. transient=sqrt(xfenergy1);
  25. %N=2048
  26. xf2=fft(x2);
  27. xfpower2=xf2;
  28. xfpower2=xfpower2.^2;
  29. Scale2=2*t1.^2;
  30. xfenergy2=xfpower2*Scale2; %Esd
  31. xfenergy2(1)=xfenergy2(1)/2; % as the factor two shouldnt be added for gxx(0) as stated in the lecture notes because of properly scaled DC value
  32. transient2=sqrt(xfenergy2);
  33.  
  34. %% Plots
  35.  
  36. plot(f1,abs(transient),'k')
  37. hold on
  38. plot(f2,abs(transient2),'r');
  39. title('trancient spectra')
  40. xlabel('frequency[k]');
  41. ylabel('Ns');
  42. legend('Original signal','block length(N=2048)')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement