## Wednesday, November 11, 2009

### On Confirming Sine Waves

I was recently asked what was the best way of confirming that a given measured waveform was a sine wave. It was a simple question, but that got me thinking...Its easy enough to eyeball a waveform and give a quick judgment, but when one really has to be sure, how to go about this?

If the frequency of the expected sine waveform is known, One method would be, to take the cross-correlation between the measured signal and the ideally expected one.

But the most foolproof way, is to take the fourier transform of the waveform. This gives a lot more information than the correlation, it actually tells you what all frequencies make up your wave. Matlab has an implementation of the fast fourier transform (called fft for short).

The fourier transform of a sine wave of a frequency f, is two dirac delta functions of half the amplitude of the original wave. When plotted on a frequency vs. amplitude plot, they show up as two lines at f, -f with half the amplitude of the original wave.

The Fourier Transform method, however, also has to caveats. The fourier transform function expects an infinite waveform as an input. The measured signal would be anything but that (because of equipment limitations/practicality). Hence, a windowing function is needed to attenuate the edges. The other gotcha is, that sometimes, Harmonics of a single frequency will show up on the fourier transform, i.e. spectral lines at 1f, 2f etc if f was your expected frequency. In such cases, the amplitude of the main f frequency spectral line to the other harmonics' amplitude serves as a good indicator of how good the signal is.

This post diverts from my other more systems-like posts, but I just realised that this is hands-on stuff, that probably doesn't get published anywhere, and hence noteworthy.

p.s. There's also a C implementation of the Fast fourier transform from MIT. Cheekily, its called the fastest fourier transform in the west(FFTW) :)

#### 1 comment:

Lakshmipriya said...

You can also do fft, ifft on excel, for those not too comofratble with their skills in either matllab or excel... if you dont have too much data