1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fourier Transform : Analysis of 2 different signals

  1. May 8, 2013 #1
    Hi,

    I was wondering what would the Fourier transform of a signal like below give:

    s(t) = sin(2πt*10) ; t in [0s,5s]
    = sin(2πt*20) ; t in [5s,10s]

    I certainly did not expect it to give me 2 sharp peaks at frequencies 10Hz and 20Hz - because I understand that the addition of sine waves of frequencies obtained from Fourier Transform will give me original signal - so I'd expect to see two sharp peaks (at 10Hz and 20Hz) for something like...

    r(t) = sin(2πt*10) + sin(2πt*20) ; t in [0s,10s]

    I did a fast Fourier transform [using Matlab fft] of the above two signals.. and I obtained more or less the same peak frequencies in both : 10Hz, 20Hz. In the fft(s)There are some other low frequency components, which have considerably low amplitudes than above two frequencies.

    Am I missing something? Or those low amplitude frequency components are all that are required to change s(t) into r(t)?
     
  2. jcsd
  3. May 8, 2013 #2

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    The original signal consists of alternate 5s bursts of 10Hz and 20Hz - that could be looked upon as 0.1Hz square wave AM of each of two 'carrier' frequencies. If you look at the FT of each of these in turn, you'd expect a fundamental and a 'comb' of sidebands, at +-0.1Hz,+-0.3Hz, +-0.5Hz etc (odd harmonics of the square wave) , I think. The amplitude of the first sideband would be 1/2 that of the carrier and, thereafter, the amplitudes would follow a sinx/x amplitude distribution.

    Whether you use both frequencies or just one, I would have expected that you'd get the same sideband structure around each carrier. If you aren't getting it then I wonder if your input data is, in fact, what you think it is. Just a suggestion - it's always worth checking.
     
  4. May 8, 2013 #3

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    The OP didn't say what was the sampling rate for the FFT's. A (fairly low) sampling rate chosen to show the peaks at 10 and 20 Hz might not have enough resolution to show the sidebands clearly.
     
  5. May 9, 2013 #4

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    How would the sampling rate affect the displayed sidebands; isn't that down to the repeat rate, which would seem to have been 10s? The sampling rate is only relevant when under-sampling a 'real' signal, which generates aliases. I'm assuming that the samples would be specified to sufficient (floating point number) accuracy.
     
  6. May 9, 2013 #5

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    If you have sidebands with a spacing of exactly 0.1 Hz, but the frequency resolution of the FFT is not an exact sub multiple of 0.1 Hz (and it won't be, if you take ##2^n## samples in 10 seconds), something's got to give somewhere.

    The more sample points you take, the closer the FFT will be to the "exact" sideband spectrum.

    Of course there is no reason why you can't take say 1000 sample points rather than 1024. A good FFT routine will work efficiently for any number of points that can be factored competely into small prime numbers (like 2 and 5) - it doesn't have to be an exact poiwer of 2. (And for doing just one FFT on 1000 points, efficiency doesn't really matter anyway on a modern PC).
     
  7. May 9, 2013 #6

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    So where does this leave us? It seems to me very unlikely that there is anything to account for the complete (absence) of these square wave mod sidebands - even if there may be some slight error in the levels produced by the FT. Even if the 20Hz waveform were to be represented as crudely as 1010etc1010000etc0000001010101etc0101000000etc00000 (i.e. bursts of 20Hz square wave and equal periods of zero) and the 10Hz waveform were represented by 110011etc00110000000000etc000000110011001etc1001100100000etc00000 (bursts of 10Hz square wave), the FT should still throw up two carriers and two sets of sidebands. If there were 'round numbers' of cycles, to add up to 100, or 1000 or 10000, the resulting FT would have no 'errors', I think.
     
  8. May 9, 2013 #7

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    The signal defined by the OP's mathematical function has infinite bandwidth. If you sample it and take an FFT of the sampled data, the sampled data has a finite bandwidth.

    Ususally the difference isn't very important, but strange things can happen.

    But I agrree, I would expect to see some sort of sideband pattern, unless the OP is plotting the data in a misleading way somehow.
     
  9. May 9, 2013 #8

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    I don't think you can say that. Is not the bandwidth of a series of samples actually infinite, whether they are impulses or box-car? The sidebands associated with the square wave modulation will mostly be very much in-band and should appear as such after the DFT. The mathematical operation of the DFT 'assumes' a limited range of frequencies, the (implied) range is imposed by the sample interval / sampling rate. If the signal were to be sampled at a very much higher frequency, the difference would only be slight and would, I think, just be in the form of the higher harmonics (and their alias products) of the two carriers. Your "strange things" would, surely, be very low order; you can't fool the Maths.
    Actually, we may be in agreement about this and it could be just the way we are each putting it.
    However, as you say, it's possible that the output result may be plotted / displayed wrongly. It would be of interest if, as I suggested, just 20Hz and 10Hz signals were analysed separately.
     
  10. May 9, 2013 #9

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    Mr Nyquist said it before I did.

    Without getting into the math (which should be in any good reference on fourier analysis or digital signal processsing), the basic reason is that you can't represent an arbitrary infinite-bandwidth signal with only a finite number of fourier coefficients.

    For sampled data, each sample point doesn't correspond to a delta function, but a ##A\sin(kt)/t## function which = ##A## when ##t = 0## and ##k## depends on the sample rate, to make the function zero at all the other sample points.

    Uusally all the "iwggles" average out to give a smooth looking function, but not necessarily.
     
  11. May 9, 2013 #10

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    I agree that the frequency domain description of a time varying function cannot give any information about frequencies which are outside its range but we are dealing with frequencies that are very much inside its range. But a string of samples of a waveform will have wide / infinite frequency spectrum. The theory behind the sampling of an original continuous function is not really relevant here because the samples are already defined / artificially produced.
    The OP is starting with a series of mathematically defined samples, which represent the amplitude at a given set of instants - impulse samples, which say nothing at all about the values of the signal at intermediate times. It does not imply boxcar samples - or any other arbitrary transition between the values. Nyquist filtering before sampling ensures that the samples follow the rule you stated. There are only practical reasons for using boxcar sampling (which contributes to the low pass (Nyquist) filtering).
    Your sinx/x function is only relevant for boxcar sampling and is just an added complication affecting the original production of the numerical samples.
    But I don't think any of this is relevant to the lack of sidebands - just, possibly to small details in their amplitudes.
     
  12. May 9, 2013 #11
    Do you mean that if I do a Fourier transform of a single 10Hz signal, still I'd get sidebands? Why is that?

    Here is the information about my plots.

    Using Matlab, I defined a 10Hz signal as :
    Ft=sin(2*pi*[0:0.001:5]*10)
    That is 1000 samples per second.

    On plotting the function abs(fft(Fx)), I got a single peak without any significant sidebands.

    The original signals that I plotted were the fft of:
    Rt = sin(2*pi*[0:0.001:10]*10) + sin(2*pi*[0:0.001:10]*20)
    and,
    St = [sin(2*pi*[0:0.001:4.976]*10),sin(2*pi*[0.039:0.001:5.063]*20)]

    (the weird numbers for St above, are because I tried to match the minima of the two sine-waves at the point of contact, and further trimming the whole signal to 10s).

    The fft for Rt above gave two peaks, much similar to that in case of Ft.
    For St, there are a number of small wiggles around two significant peaks.
     
  13. May 10, 2013 #12

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    Did you not take my point about the fact that there is square wave AM of each sinusoid involved? I suggest you look up Frequency Shift Keying to see what I mean. This is another way of looking at things.
     
  14. May 10, 2013 #13

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    I'm going to disagree with your logic, independent of whether your conclusions are right or not.

    A set of sampled data is just a list of numbers. The numbers don't "know" what the person who created them thinks they are supposed to represent - data from a contunious mathematical function, impulses, boxcar samples, or whatever.

    The simple way to see that you "should" get sidebands here is to think about continuous signals, not sampled data. You are multiplying a sine wave by a square wave, you know the Fourier series for both of the above, and you know that ##\sin(at)\sin(bt) = (1/2)(\cos(a-b)t - \cos(a+b)t)##, etc.

    But the OP made a plot by doing something completely different from that! If the results are different, then excluding blunders like typos etc, the explanation must be the difference between the continuous functions and the sampled data.
     
    Last edited: May 10, 2013
  15. May 10, 2013 #14

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    Rt is just the sum of two sine waves, not 5 seconds of one frequency followed by 5 seconds of a different frequency. So you would expect to get two peaks and nothing else.

    I'm not quite sure where the "weird numbers" came from, but St is more like the function you defined in your OP, and apparently you did get some sidebands in the FFT.

    FWIW defining
    St = [sin(2*pi*[0:0.001:4.9999]*10),sin(2*pi*[5:0.001:10]*20)]
    should work. The 4.9999 is to make sure you don't get two samples at t = 5 sec, one from each part of the definition.
     
  16. May 10, 2013 #15

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    doesn't appear to be the same as
    as that expression seems to have both signals 'on' for more or less all the time. (If the notation is how it appears to be; I am not exactly sure what the convention is.)

    but AlephZero's
    looks far more like your original. can you actually plot your time domain signal as defined in the two different ways? Does it acgtually look like what you want?
    I think it may have been a case of GIGO :smile:, which should be reassuring because nothing has shaken the foundations of accepted theory.

    @AlephZero
    I think we must be looking at this from different viewpoints. We both have the same text book information about sampling theory but I think you are basing your thinking in terms of starting with a real input signal - which the OP is not.
    A sample is a sample -i.e. the value of a variable at a particular time. Samples do not interfere with each other or contribute to other values unless some inappropriate filter makes it happen. This is the advantage of dealing with impulses. The calculated samples are just what they say they are (but, of course, there are a million different real input signals that could produce those same samples if Nyquist filtering is not used) and theory says that you can generate a perfect version of a sampled (low-pass filtered) signal as long as your filter has a Sinc characteristic when you re-constitute. But this is not relevant because it's a simulation. So, as we are looking for very much in-band products, I see no reason why they should not turn up just as expected. The carriers are well separated so the sidebands of each would not be expected to affect each other noticeably as they have dropped off in level by the time they start to overlap. You might expect something different if the two carriers were only 0.1Hz apart.
     
  17. May 10, 2013 #16
    I defined it the way I did.. so that it remains differentiable over whole period of 10s.. maybe that was not needed.


    If you read my first post.. I just wanted to confirm that the sidebands I am getting are all that is needed to change Rt into St. I had expected transform of Rt to be just two peaks.. but I also expected the transform of St to be more diffuse (and complicated).. rather than having two sharp peaks, with just a few (that too, very small magnitude) sidebands.
     
  18. May 10, 2013 #17
    The way it works in Matlab, above definition of St will concatenate the two arrays. So we will get roughly (4977+5063-38) 10,000 samples for the entire duration of 10s. (I further trimmed it to be of exact 10000 samples).
    So it is more or less like AlephZero's definition.. except that this one is differentiable at the point of contact.

    @AlephZero - In your case the signal jumps at 4.999s... won't that result into some other noisy frequencies in the transform? I wasn't sure about that.. so I removed that possibility.
     
  19. May 10, 2013 #18

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    You may be getting rounding errors because you are defining an array using floating point variables. (I tried to look up exactly how matlab does that - the documentation referred me to a technical note but the link to it on the website was broken!)

    If you are not getting the exact number of poiints you expect, it would be better to write something like sin(2*pi*[0:4999]*0.001*10) etc

    Then you know you will get exactly 5000 points, at the times you want.

    If you were getting more than 10000 points and then truncated the array, remember the function is supposed to be periodic, so you probably introduced a glitch between the start and the end of the data while you were trying to fix the glitch in the middle.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook