Take the 2-minute tour ×
Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. It's 100% free, no registration required.

I have a set of samples that represents a waveform. This waveform resembles a frequency modulated sinusoidal wave (only it is not).

I would like to invert this waveform or shift it by $2\pi$ shift it by $\pi$. of course taking the cosine of samples as they are without preprocessing is wrong.

What should I do to achieve this?

Thank you.

share|improve this question
Shifting by 2π is the same as doing nothing. I guess it's not what you want. Can you clarify the question ? –  Frédéric Grosshans Nov 23 '10 at 13:08
you are right, it wouldn't do a thing! what I would like to get is a mirror reflection of the waveform over the x-axis but with the same dc-component as the original waveform (I don't want to shift it on the Y-axis). –  mbadawi23 Nov 23 '10 at 13:26
Do you mean you have a Fourier spectrum of the waveform? –  ptomato Nov 23 '10 at 13:31
I think my problem that I was shifting by $2\pi% instead of just pi, Dah! And thanks Frédéric Grosshans. I'll share my answer with you guys. –  mbadawi23 Nov 23 '10 at 13:36
What does this have to do with physics? –  endolith Nov 24 '10 at 1:08
show 2 more comments

2 Answers

Based on what you write in the comments, perhaps you can just calculate the DC component by taking the average, subtract that, flip it over the X axis, and add the DC component back.

share|improve this answer
Yes, but how exactly do you suggest to flip it over the x-axis? –  mbadawi23 Nov 23 '10 at 15:37
Multiply by -1? –  mtrencseni Nov 23 '10 at 17:22
@mbadawi23 : another way to apply @mtrencseni solution. Compute the average $a$, and replace each sample $s_i$ by $2a - s_i$ –  Frédéric Grosshans Nov 26 '10 at 15:42
add comment
  • For each sample I calculated the angle $\theta = i * 2\pi$
  • Then I added $\pi$ to $\theta$ while calculating sine and cosine components.
share|improve this answer
This solution is way more complex than @mtrencseni 's solution, at least for an angla as simple than $\pi$ –  Frédéric Grosshans Nov 26 '10 at 15:44
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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