I have problem, not sure how to call it but I think it's something called "phase rotating", but not sure.

I make fast Fourier transform on simply square wave, and then I make inverse fast Fourier transform - just for fun :) and after this forward/backward FFT on square wave I expect on a wave graph something like that: enter image description here

But I get that: enter image description here

Could anyone help me, which parameter I should change, to fix it?

  • $\begingroup$ did you change the data after the FFT and before the iFFT? it does look like a phase change, but even a phase change requires changing the data. $\endgroup$ – robert bristow-johnson Apr 29 '18 at 23:43
  • $\begingroup$ I am not sure what you are asking. I didn't change anything. Just make FFT and on the output of FFT I make inverse FFT, that's all. $\endgroup$ – pajczur Apr 29 '18 at 23:57
  • $\begingroup$ I tried it with the radix-2 FFT and mixed radix FFT, and the same results. $\endgroup$ – pajczur Apr 29 '18 at 23:57
  • $\begingroup$ maybe it's important: on the output of forward FFT I perform magnitude calculations by: $ \sqrt { real^2 + imag^2 } $. But on the output of inverse FFT I just take real values without any calculations. Maybe I should use in some way the imaginary numbers also? $\endgroup$ – pajczur Apr 30 '18 at 0:01
  • $\begingroup$ The output of your fft should yield complex number. You must feed the same complex number to the ifft to get the same result as the input of the fft. If you do the ifft of the magnitude of the spectrum, you'll get a different result. Also, you could share your code, that would help $\endgroup$ – Pier-Yves Lessard Apr 30 '18 at 0:30

Ok I give the answer by myself, but it’s only half of answer. As I know we can rotate $ 90^o $ the phase by multiplying the wave by $ j $ - imaginary number. And to rotate it to $ 180^o $ we need multiply by $ j^2 $ (or just $ -1 $ which is the same). To rotate $ 270^o $ we need to multiply by $ j^3 $, and so on...

But if we want rotate something between? For example $ 45 ^o $ or $ 30^o $. What we need to multiply by?

  • $\begingroup$ Use Euler's formula: $\cos(\theta) + j\sin(\theta)$ to rotate by $\theta$. $\endgroup$ – user827822 Jul 1 '18 at 7:25
  • $\begingroup$ Thanks firdes, your comment is helpfull. I had figured it out by my own that to rotate by some angle between 0-90 degree I just need to multiply signal by $i^(something between zero and one)$. But your comment gives me answer how to rotate by exact degree. Thanks. $\endgroup$ – pajczur Jul 1 '18 at 8:00

To answer your second question, which is in your supplemental answer.

See my blog article for more details. https://www.dsprelated.com/showarticle/754.php

I like to use $i$, instead of $j$.

The underlying rule, which comes from the exponential nature of the unit circle, is that when you multiply two complex numbers their angles get added. Thus the angle to $i$ is $90^o$ ($\pi/2$ radians), so every time you multiply by $i$ you rotate the complex number by a quarter circle. The other rule about multiplying complex numbers is that the magnitude of the product is the product of the magnitude. Since $|i|=1$ it doesn't stretch any number you multiply it by.

You can rotate any complex number by $p$ quarter circles by multiplying it by $i^p$. You can pick any point on the unit circle, and if you multiply a complex number by the value of the complex number at that point, you will rotate the first complex value by the angle to the point.

Again, read my blog article on this. It builds up to Euler's equation using simple to understand algebra.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.