Facebook
From Harmless Frog, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 205
  1. clc
  2. close(gcf)
  3. clear all;
  4. disp('Wykreślanie wsp. szeregu Fouriera dowolnej funkci');
  5. funs=input('Podaj wzór funkcji f(t)=','s');
  6. tk=input('Podaj czas końcowy tk[s]=');
  7. Lp=1024;
  8. Tobs=tk-0;
  9. df=1/Tobs;
  10. fmax=df*Lp/2;
  11. t=[0:Tobs/Lp:Tobs-Tobs/Lp];
  12. fun=eval(funs);
  13. subplot(2,2,1)
  14. plot(t,fun);
  15. title('Przebieg funkcji f(t)');
  16. xlabel('Czas t[s]');
  17. grid on
  18. FUN=fft(fun);
  19. FUNp=FUN(1:Lp/2)/Lp*2;
  20. FUNp(1)=FUNp(1)/2;
  21. m=abs(FUNp);
  22. subplot(2,2,2)
  23. f=[0:df:fmax-df];
  24. axis([0 fmax 0 max(m)]);
  25. hold on
  26. grid on
  27. bar(f,m);
  28. title('Widmo amplitudowe funkcji f(t)-współczynniki abs(cn)')
  29. xlabel('Częstotliwość f[Hz]');
  30.