0

I have a data (file) which contains 2 columns:

Seconds, Volts
0, -0.4238353
2.476346E-08, -0.001119718
4.952693E-08, -0.006520569
(..., thousands of similar entries in file)
4.516856E-05, -0.0002089292

How to calculate the frequency of the highest amplitude wave ? (Each wave is of fixed frequency).

Is there any difference between calculating frequency of seconds and amplitude vs. seconds and volts? Because in Frequency & amplitue there is seconds and amplitude example solved, so it might help in my case.

nanomader
  • 410
  • 9
  • 22
  • 1
    What do these data mean? Are those samples of a single wave in different time instants? Or is it something else? – Roman Hocke Dec 11 '15 at 14:55
  • @RomanHocke yes, those are samples of a single wave taken from one large file (thousands of these values). And I have many files similar to this one. – nanomader Dec 11 '15 at 14:57
  • 1
    I presume that You are sure that You have enough samples per period. Then I would try to find monotonous segments in the signal (ascending segments and descending segments). If You are sure that the signal is supposed to be a sinusoid, You can determine average period from the time length of those segments. – Roman Hocke Dec 11 '15 at 15:01
  • 1
    You have to ascertain then length of time it takes your voltage to pass the same point in the same direction - and then extrapolate the number of times it does that in a second. IOW, you'll need to do a lot more work before this becomes a debugging problem (which is the purpose of SO) – KevinDTimm Dec 11 '15 at 15:01
  • 1
    If there is supposed to be some noise in the signal, then it can pass through certain point (or zero level) or switch monotonicity many times per period, which may confuse Your computations... – Roman Hocke Dec 11 '15 at 15:04
  • @RomanHocke What I have to do with this data is to: output a file, containing the waveform filename in the first column and the waveform frequency in the second column. And sort the results by ascending frequency. What I want to know is how/what calculations I have make to calculate that? I'm reading currently about DSP, TFFT, but I'm completely beginner in this field. – nanomader Dec 11 '15 at 15:36
  • 2
    @RomanHocke: Given that we know it's a single frequency, **3** samples is technically enough for a sinusoid (in the non-degenerate case). You're solving `a*sin(b*t+c)` - 3 unknowns. – MSalters Dec 11 '15 at 16:16

1 Answers1

3

Your data is in the time domain, the question is about the frequency domain. Your course should have told you how the two are related. In two words: Fourier Transform. In practical programming, we use the FFT: Fast Fourier Tranform. If the input is a fixed frequency sine wave, your FFT output will have one hump. Model that as a parabola and find the peak of the parabola. (Finding the highest amplitude in the FFT is about 10 times less accurate)

The link you give is horrible; I've downvoted the nonsense answer there. In your example, time starts at t=0 and the solution given would do a 1/0.

MSalters
  • 173,980
  • 10
  • 155
  • 350