Advertisement
Guest User

Untitled

a guest
May 24th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.83 KB | None | 0 0
  1. clear all;
  2. close all;
  3. clc;
  4.  
  5. % Frequência de Amostragem
  6. fs = 10000;
  7. % Tempo de 10 segundos
  8. t = 0:1/fs:10;
  9. % Frequência normal
  10. fnormal = 60;
  11. % Definindo a frequência angular
  12. W = 2*pi*fnormal;
  13. % Definindo a amplitude
  14. A = 1;
  15. % Definindo a fase
  16. phi =  pi/2;
  17. % Função x(t) original e as função deslocadas
  18. x = A*sin(W*t+phi);
  19.  
  20. normal = length(x);
  21. aux    = 0:normal-1;
  22. T      = normal/fs;
  23. freq   = aux/T;
  24.  
  25. X = fftn(x)/normal;
  26. fc = ceil(normal/2);
  27. X = X(1:fc);
  28.  
  29. figure();
  30. % Domínio do tempo
  31. subplot(2,1,1)
  32. hold on
  33. axis([0 0.2 -1 1])
  34. plot(t,x,'r');
  35. xlabel('Tempo','FontSize',12);
  36. ylabel('Amplitude','FontSize',12);
  37. % Domínio da frequência
  38. subplot(2,1,2)
  39. hold on
  40. axis([0 120 0 0.6])
  41. plot(freq(1:fc), abs(X));
  42. xlabel('Freq.(Hz)', 'FontSize', 12);
  43. ylabel('Amplitude', 'FontSize', 12);
  44.  
  45. print -dpng FFT1.png
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement