Facebook
From Sloppy Bat, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 191
  1. fs=1000; %czestotliwosc probkowania
  2. f0=110;  %czestotliwosc sygnalu
  3.  
  4.  
  5.  
  6. for ind=10:15
  7.  
  8. N=2^ind;     %liczba probek sygnalu
  9. t=(0:N-1)/fs;
  10. x=cos(2*pi*f0*t);
  11.  
  12. %metoda bezposrednia
  13. kern=1i*2*pi/N;
  14. X=zeros(N,1);
  15. Wrow2=exp(kern*(0:N-1));
  16.  
  17. t=cputime;
  18. X(1)=ones(1,N)*x';
  19. X(2)=Wrow2*x';
  20.  
  21. for k=3:N
  22.    
  23.     X(k)=exp((k-1)*kern*(0:N-1))*x';
  24. end
  25.  
  26. elapsed_timeDirect(ind)=cputime-t
  27.  
  28. %  figure
  29. %  subplot(2,1,1)
  30. %  plot(1:N,real(X),1:N,imag(X))
  31.  
  32. %metoda FFT radix2
  33. t=cputime;
  34. X=myFFT(x');
  35. elapsed_timeFFT(ind)=cputime-t
  36.  
  37. end
  38. %% plot time
  39. N=2.^(1:15);
  40. figure
  41. plot(1:length(elapsed_timeDirect),log10(elapsed_timeDirect),'x',1:length(elapsed_timeDirect),log10(elapsed_timeFFT),'o',...
  42.     1:length(elapsed_timeDirect),log10(elapsed_timeDirect./N/1.*log2(N)))