-1
$\begingroup$

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.

$\endgroup$
7
  • 1
    $\begingroup$ Shifting by 2π is the same as doing nothing. I guess it's not what you want. Can you clarify the question ? $\endgroup$ Commented Nov 23, 2010 at 13:08
  • $\begingroup$ 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). $\endgroup$
    – mbadawi23
    Commented Nov 23, 2010 at 13:26
  • $\begingroup$ Do you mean you have a Fourier spectrum of the waveform? $\endgroup$
    – ptomato
    Commented Nov 23, 2010 at 13:31
  • $\begingroup$ 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. $\endgroup$
    – mbadawi23
    Commented Nov 23, 2010 at 13:36
  • 1
    $\begingroup$ What does this have to do with physics? $\endgroup$
    – endolith
    Commented Nov 24, 2010 at 1:08

2 Answers 2

2
$\begingroup$

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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