开发者

Fourier Transformation help

开发者 https://www.devze.com 2023-02-12 13:40 出处:网络
I\'m suppose to do some work with Fourier transformations and I\'m still really confused. I\'m given a signal (in this case it is f[t] = sin(2 pi s t / N) where s = 8 and N = 128)

I'm suppose to do some work with Fourier transformations and I'm still really confused.

I'm given a signal (in this case it is f[t] = sin(2 pi s t / N) where s = 8 and N = 128)

And I'm suppose to find the Real, Imaginary, Phase, and Magnitude.

I understand how to get the Real and Imaginary, but the Phase and the Magnitude are beyond me...

the sudo code for getting the Real and the Imaginary is:

for u 开发者_高级运维= 0 to M-1 do
F[u].real = 0
F[u].imag = 0
for x = 0 to M-1 do
    F[u].real += f[x] * cos(- 2 * pi * u * x / M)
    F[u].imag += f[x] * sin(- 2 * pi * u * x / M)
end do
F[u].real /= M
F[u].imag /= M
end do

Now somewhere in there is the phase and the magnitude, but where?!

Thanks!

Also, some programmer-equse explination of the basics of FTs would be wonderful as well!


If you think to real and imaginary components as coordinates in an XY plane then the phase is the angle between the vector and the X+ axis, and the magnitude is the length of the vector. To compute then you just need

magnitude = sqrt(real*real + imag*imag)
phase = atan2(imag, real)


From http://en.wikipedia.org/wiki/Complex_number#Absolute_value_and_argument:

  • The magnitude is sqrt(real^2 + imag^2) (where ^ denotes "squared").
  • The phase is atan2(imag, real) (where atan2() denotes the two-argument arctan function).

That Wikipedia article explains why better than I can do justice here.

0

精彩评论

暂无评论...
验证码 换一张
取 消