I know there are dozens of questions about how to extract the correct frequency out of data, however I probably don't interpret my data correctly, or do not apply those answers correctly.


I recorded data with an oscilloscope of a free running laser. The laser output is not constant, instead it has a pulsed behaviour, and I want to extract the main frequency (if it exists)

pulse = Import["http://ge.tt/api/1/files/9xhaouB2/0/blob?download", "Table", "HeaderLines" -> 5];

ListLinePlot of Pulse

I processed the data with periodogram, given the sample rate of the data:

Periodogram[pulse[[All, 2]], SampleRate -> 5*10^6, Frame -> True,
GridLines -> {{5500}, None},
FrameTicks -> {{All, All}, {All, All}},
 GridLinesStyle -> Directive[Red, Dashed], AspectRatio -> 1/4,
 ScalingFunctions -> "dB", PlotRange -> {{0, 100000}, {-30, -100}},
 ClippingStyle -> None]

Enter image description here


  1. From a first view I would think that there should be a dominant frequency around 5500 Hz (if it's an artefact, or real is another question).

  2. Periodogram: Why do I need the [All, 2]? I copied it from another question here, but I can not locate it anymore and can not find the reason. Did I use the periodogram correctly, or is it just fortune that I have a negative (why?) peak at 5500?

  3. How do I get the same picture with the Fourier transform? I tried the solution from Fourier transform of sampled data:

    samplerate = 5000000; time = Length[pulse]/samplerate; nyq = Floor[Length[pulse]/2]; ListPlot[Take[ 10*Log10[(Abs@Fourier[pulse, FourierParameters -> {1, -1}])^2], nyq], Joined -> True, PlotRange -> Full, DataRange -> {0, (nyq - 1)/time}]

which creates absolutle nonsense (or I did). In principle, all the questions/answers are about scaling correctly the x-axis, but at least I did not get what I would have to do for my data.

Enter image description here

  1. Is there a smart way to work with such datasets when they are bigger in Mathematica? The data shown here is a subset of the data, as the original one with a size of 20 MB used up to 3 GB of RAM on my computer.
  • $\begingroup$ What made you think the dominant frequency is 5500 Hz ? $\endgroup$
    – Sektor
    Mar 9 '15 at 19:51
  • $\begingroup$ Just a rough measure of the distance between two peaks ~ ok well i checked some other, there its not 5500 Hz :) I do not know if FT is the right tool for that ? In Origin i tried before something different - finding peak maximas and calculating from them a mean frequency, but thought that a FT would be more sophisticated $\endgroup$
    – Bastian
    Mar 9 '15 at 20:35
  • 1
    $\begingroup$ I use this simple rule - if it is a stationary signal - FT, if not - wavelet, chirplet, ridglet, etc $\endgroup$
    – Sektor
    Mar 10 '15 at 11:22
  • $\begingroup$ This exceeds my knowledge about signal processing. My Physics background ends at ft. Googles search after definition tell me i have a non-stationary signal. So you statefor my type of data the FT is than not the appreciate tool, instead e.g. wavelet. Would the spectrogram in mathematica be the right way to focus first?(even though its not working for my data ?) $\endgroup$
    – Bastian
    Mar 11 '15 at 21:18
  • $\begingroup$ Okay, a question - what information are you seeking to obtain ? Time-frequency, frequency-db ? Those things require different tools. Try plotting the spectrogram and you will see the evolution of the frequencies present in the signal over time. $\endgroup$
    – Sektor
    Mar 11 '15 at 22:53

This is a regularly sampled data set - we can work with the y values only, discarding the time steps. This is what you are actually doing when using pulse[[All, 2]] - from every pair of values you are taking the second entry - the amplitude. To answer your third question you just use pulse[[All, 2]] instead of just pulse when computing the Fourier transform of the set and you will end up with exactly the same plot. Question #4 is a whole different story - you should try searching for related questions and have to start getting your hands dirty.

Now, here's a little something that you can try tweaking to suit your needs.

data = Table[Sin[2 π 100 t] + RandomVariate[NormalDistribution[0, 1]], {t, 0, 4999/1000, 1/1000}];

len = Length@data;

pdata = HammingWindow /@ Partition[data, Floor[len/10], Floor[len/16]];

fdata = Mean[10 Log10[Abs[Fourier /@ pdata]]];


Mathematica graphics


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.