Electronic – Trying to determine the SNR of a dirty signal

MATLABsnr

I have a dirty sine wave at about 8 Hz, and I want to figure out the SNR using MATLAB.

Would a reasonable approach to answering this question be to generate a clean 8 Hz sine wave in MATLAB and then use that to compare to the dirty signal to find the SNR? My thinking is that the clean sine wave is the ideal we would want.

I am not sure if there would be any phase issues in doing this.

I know MATLAB has an snr function, but I would like to be able to calculate it to compare to the function.

As a reference, the signal with noise could look something like this

enter image description here

Best Answer

Start with the definition of SNR, signal power to noise power ratio.

Take an FFT of your waveform. Classify each bin as containing signal or noise. Sum the power in all the signal bins to get signal power. Sum the power in all the noise bins to get noise power. Take the ratio.

You have some choices about how you set up the FFT, and how you classify the bins around the signal frequency. Do you use a window, and if so which one, and what does it do to the signal, and what does it do to the noise?

Parseval's Theorem is very useful here in getting one's ideas straight. Obviously a synchronously sampled signal that allows you to avoid a window and still convert without aliasing is the simplest situation to understand first.

MATLAB is very handy for this sort of task, as you can generate known signals with known noise additions, analyse them, and check you get the answer you expected. Hint, seeing noise on a graph is rather easier than understanding exactly what the noise measurements mean quantitively. It's worth comparing with MATLAB's SNR function, but you'll need to understand exactly what choices it is making for the signal classification.