Summation of Sine waves

  • #1
37
0

Main Question or Discussion Point

Hi

I just wanted to check my approach. I have spectrum I have peak at 10Hz another at 20Hz and a third at 30Hz. The amplitudes are 1000, 500, 250. I want to recreate the signal by summing sine waves.

I assume that I will therefore take
A1 = 1;
A2 = 0.5;
A3 = 0.25;

I will then let y = A1*Sin(2*pi*1000*t)+A2*Sin(2*pi*2*500)+A3*Sin(2*pi*3*250);

Is this correct because when I look at my end result it is not as I wish it to be.

Sorry for mistake in post due to my english
 

Answers and Replies

  • #2
11,804
5,424
I think you forgot the t variable in the second and third terms, right?

And shouldn't the A1, A2, A3 be 1000, 500, 250 instead of what you wrote?

And lastly, the arguments for the sin terms should be of the form \omega * t and should somehow reflect the 10, 20, 30 hertz values not the amplitudes, right?
 
  • #3
Khashishi
Science Advisor
2,815
493
Do you know the phases between the waves?
 
  • #4
vela
Staff Emeritus
Science Advisor
Homework Helper
Education Advisor
14,632
1,268
I will then let y = A1*Sin(2*pi*1000*t)+A2*Sin(2*pi*2*500)+A3*Sin(2*pi*3*250);

Is this correct because when I look at my end result it is not as I wish it to be.
Besides the missing factor of ##t##, why did you put those red factors in? They shouldn't be there.
 
  • #5
37
0
Hey yea sorry I did include errors in my original post so what I actuallly have is

y = A1*Sin(2*pi*10*t)+A2*Sin(2*pi*20t)+A3*Sin(2*pi*30t);

the 2 and 3 reflect that they are second and thrid harmonic?

Also have I determined my amplitudes correctly?
 
Last edited:
  • #6
1,184
222
If I remember correctly, the resultant amplitude by Fourier analysis should be near
gif.gif
 
  • #7
37
0
Sorry for the error above. I have corrected it now. I should not include the 2 and 3 if I also use the new frequencies. If I stay with f1 then I can use 2 and 3. Sorry I know this but I made mistake when typing up my question. So basically I have made my time series by using the above equation. I have done it in two axes however, when I plot them against eachother I do not get shape I was expecting and so this make me think I have not done synthesis correctly?
 
  • #8
f95toli
Science Advisor
Gold Member
2,996
492
The 2 and 3 should not be there, the fact that they are harmonics in this particular case does not affect the way you sum the components of the signal.
 
  • #9
37
0
The 2 and 3 should not be there, the fact that they are harmonics in this particular case does not affect the way you sum the components of the signal.
Yes agreed I am now plotting ;

y(t) = A1*Sin(2*pi*10*t)+A2*Sin(2*pi*20t)+A3*Sin(2*pi*30t);
 
  • #10
1,184
222
when I plot them against eachother I do not get shape I was expecting and so this make me think I have not done synthesis correctly?
And why should you? You don't have enough data to recreate signal waveform ( not even aproximately) .
Zillions of combinations are possible to produce peaks you're referring to...
 
  • #11
37
0
Yes I know. I have been asked ot do it as a rough guide and I am really struggling. Of course I realise that I can also have bcos(wt) in my equations. It is very tricky problem but I real appreciate you to help me! Thank you
 
  • #12
f95toli
Science Advisor
Gold Member
2,996
492
You can always reproduce the time domain signal from the spectra assuming you've captured data with enough bandwidth; what you lose with an ordinary spectra (i.e. something measured with an ordinary fft analyzer) is the relative phase of the components of the signal.
After all, if you have the spectra a simple inverse transform (ifft) will give you the time domain data.

However, coming back to the question: are you sure the spectra shows the correct amplitude of the components? Most (albeit not all) spectra actually shows the power in each peak, usually as power spectral density. You also need to be careful about the number of points in the spectra; if the measurement is fft based (which most are) you will run into trouble with the amplitudes being wrong if not enough points were used. This is a well-known artifact of the fft algorithm (which can be solved using e.g. zero-padding)
 
  • #13
37
0
Hi, Well I have quite a bit of data and I am using FFT which I believ gives (absolute magnitude or amplitude) This is correct? I have not use Spectrograph or power spectra? I also realise I should use cosine really to deal with phase but I am not sure how to determine corret combination
 
  • #14
Khashishi
Science Advisor
2,815
493
The FFT is in general a complex function. You know what a complex number is, right? The real part of the peak value tells you about the cosine component and the imaginary part tells you about the sine component.

The sample rate needs to be higher than twice the bandwidth of the signal for you to reconstruct the signal from the FFT. But if you are simply trying to reconstruct the sample points, that won't be an issue.
 
  • #15
37
0
Ahh Ok that is very helpful and so if I look at these values and say the values at 20Hz is some 0.52 + 0.99i (made up) I then use 0.52 as my a coefficient for the cosine part and 0.99 for the sine part?
 
  • #16
Khashishi
Science Advisor
2,815
493
Not quite. In general, you have to look at both positive and negative frequency components of the FFT. If you know that the original signal is real, then you can ignore the negative frequency components (which will just be equal to the complex conjugate of the positive frequency component. For your example, at -20Hz, you should have 0.52 - 0.99i.)
You need to multiply the number at +20Hz by 2 since you are throwing away the -20Hz value.
So 0.52*2 for the coefficient for the cosine, and 0.99*2 for the sine.

Also, depending on how the FFT routine is normalized, you might need to also multiply by another number. FFT routines are all different in how they normalize the output!
 
  • #17
boneh3ad
Science Advisor
Insights Author
Gold Member
3,103
779
Not quite. In general, you have to look at both positive and negative frequency components of the FFT. If you know that the original signal is real, then you can ignore the negative frequency components (which will just be equal to the complex conjugate of the positive frequency component. For your example, at -20Hz, you should have 0.52 - 0.99i.)
You need to multiply the number at +20Hz by 2 since you are throwing away the -20Hz value.
So 0.52*2 for the coefficient for the cosine, and 0.99*2 for the sine.

Also, depending on how the FFT routine is normalized, you might need to also multiply by another number. FFT routines are all different in how they normalize the output!
Of course, this depends on how the spectrum was reported. The OP may be looking at either a one- or two-sided spectrum, so whether there is a factor of two depends on that.

Also, in my experience, working with both sines and cosines in this sort of thing can be obnoxious. It may simply be easier to assign the complex magnitude of the FFT at a particular frequency to the amplitude of the cosine term and then take the argument of the FFT at that point and incorporate it as a phase shift.

For example, if you are trying to reconstruct ##x(t)## from its Fourier components ##X(f)##, then ##X## is complex and at a given frequency ##f_0##,
[tex]X(f_0) = a(f_0) + ib(f_0).[/tex]
You can then get the sinusoidal component for ##f_0## from
[tex]x_0(t) = A_0 \cos (2\pi f_0 t + \phi_0)[/tex]
where
[tex]A_0 = |X(f_0)| = |a(f_0) + ib(f_0)|[/tex]
and
[tex]\phi_0 = \arg X(f_0) = \arctan\dfrac{b(f_0)}{a(f_0)}.[/tex]

And of course, there may be a factor of two involved depending on the nature of the spectrum OP is reading.
 
  • #18
37
0
Thank you for the help I am trying to get the complex values at present out of the spectra that I have been given. The amplitudes are just real numbers however it seems that it fft has been used and then (abs(fft)) is plotted to give the spectra
 
  • #19
37
0
Of course, this depends on how the spectrum was reported. The OP may be looking at either a one- or two-sided spectrum, so whether there is a factor of two depends on that.

Also, in my experience, working with both sines and cosines in this sort of thing can be obnoxious. It may simply be easier to assign the complex magnitude of the FFT at a particular frequency to the amplitude of the cosine term and then take the argument of the FFT at that point and incorporate it as a phase shift.

For example, if you are trying to reconstruct ##x(t)## from its Fourier components ##X(f)##, then ##X## is complex and at a given frequency ##f_0##,
[tex]X(f_0) = a(f_0) + ib(f_0).[/tex]
You can then get the sinusoidal component for ##f_0## from
[tex]x_0(t) = A_0 \cos (2\pi f_0 t + \phi_0)[/tex]
where
[tex]A_0 = |X(f_0)| = |a(f_0) + ib(f_0)|[/tex]
and
[tex]\phi_0 = \arg X(f_0) = \arctan\dfrac{b(f_0)}{a(f_0)}.[/tex]

And of course, there may be a factor of two involved depending on the nature of the spectrum OP is reading.
Thank you so much, I have just a single sided spectra. The amplitudes have been given to me in real numbers (I dont see a complex part) and I have values up to 100Hz but the sample rate was 200Hz
 
  • #20
boneh3ad
Science Advisor
Insights Author
Gold Member
3,103
779
Thank you so much, I have just a single sided spectra. The amplitudes have been given to me in real numbers (I dont see a complex part) and I have values up to 100Hz but the sample rate was 200Hz
Ask whoever gave you the spectrum if he/she can provide the complex values for you. You'll need that for phase information.
 
  • #21
37
0
AH Ok they have provided me with the original code. And their spectra is based on the abs of the FFT. so I am guessing if I exclude that abs I should have the complex numbers?
 
  • #22
37
0
Hi everyone after researching this proble more thoroughly I have decided to use the complex amplitudes to give me the amplitudes for cos and sin however I was wondering if you guys could tell me if my approach is correct. I take the fft data (I have removed abs so that I get complex data) I then get values such as this -3.25e+002 + 4.56e+002i;

I then recreate using the formula

y(t) = -3.25e+002*cos(2*pi*f1*t)+4.56e+002*sin(2*pi*f1*t) ;

This is just an example, usually I have a fundamental frequency and lots of harmonics present. However this approach si not quite recreating the shapes that I would expect. Am I doing somethign wrong in my approach?
 

Related Threads on Summation of Sine waves

  • Last Post
Replies
7
Views
2K
  • Last Post
Replies
13
Views
760
  • Last Post
Replies
3
Views
1K
  • Last Post
Replies
6
Views
6K
  • Last Post
Replies
4
Views
2K
Replies
8
Views
1K
  • Last Post
Replies
8
Views
2K
Replies
4
Views
2K
  • Last Post
Replies
9
Views
4K
Replies
8
Views
2K
Top