Guest User

Untitled

a guest
Jul 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. function x = fft_dit(x)
  2. % FFT_DIT decimation in time fast fourier transform
  3. % x = fft_dit(x)
  4. %
  5. % Compute fourier transform of x by the decimation in time FFT.
  6. %
  7. % fft(x) = fft_dit(bitrevorder(x))
  8. %
  9. % See also fft_dif.
  10. %
  11.  
  12. p = nextpow2(length(x));
  13. Np = 2^p;
  14. if length(x) ~= Np
  15. error('Input vector length is not a power of two.');
  16. end
  17. T = zeros(Np/2, 1);
  18. for n = 0:Np/2-1
  19. T(n+1) = exp(-1i*2*pi*n/Np);
  20. end
  21.  
  22. B = Np/2;
  23. step_T = Np/2;
  24. N = 2;
  25.  
  26. for P = 1:p
  27. base_t = 0;
  28. for b = 1:B
  29. base_b = base_t + N/2;
  30. nT = 1;
  31. for k = 1:N/2
  32. t = x(base_t + k);
  33. b = T(nT) * x(base_b + k);
  34. x(base_t + k) = t + b;
  35. x(base_b + k) = t - b;
  36. nT = nT + step_T;
  37. end
  38. base_t = base_t + N;
  39. end
  40. B = B/2;
  41. N = 2*N;
  42. step_T = step_T/2;
  43. end
Add Comment
Please, Sign In to add comment