Determining Signal to Noise Ratio
Mostra commenti meno recenti
Hi everyone,
I would like to determine the Signal to Noise Ration for an electrical signal, which was already amplified. I have multiple input channels, which experience noise and sometimes a real signal, which is easily visible with the naked eye. My Input arguments are x (Voltage) and y (time). My goal is to determine the SNR accurately for all channels, to compare their SNR and performance.

I have tried using the snr-function in MATLAB in two ways:
- r = snr(x): I'm not sure if this is correct for my application since this function is meant for a "real-valued sinusoidal input signal x", which I´m not certain my signal is. Also, channels which just experience noise somehow have a higher SNR than channels with visible peaks when I use this formula.
- r = snr(xi,y): I manually estimated the noise y (not to be confused with time, I just copied the definition from MATLAB), for the upper example about 0.004. The problem is the exact same as before, channels with just noise have a higher SNR than others. Also for some reason it does not matter what I input as noise, the result from the snr-function always stays the same.
One last question: Can a channel which does not record a valuable signal, just noise, even posses a SNR? Maybe thats part of my mistake.
I know I´m doing something wrong or I´m missing something, any help would be greatly appreciated!
1 Commento
rng(100);
fs = 48e3;
t = 0:1/fs:1-1/fs;
A = 1.0;
powfund = A^2/2;
a = 0.4;
powharm = a^2/2;
s = 0.1;
varnoise = s^2;
x = A*cos(2*pi*1000*t) + ...
a*sin(2*pi*2000*t) + s*randn(size(t));
defSNR = 10*log10(powfund/varnoise)
figure
snr(x)
copyobj(gca,figure)
xlim([0 50])
If the sampling frequency is 48 kHz, how can the frequency axis go out to 500 megaHz?
Why is the fundamental shown at 21 mHz, as opposed to 1 kHz?
Why is the noise power shown at around -60 dB? Shouldn't it be around
10*log10(varnoise)
which would then result in the expected (and shown) snr of 17 dB, because the power in the fundamental is
10*log10(powfund)
Can anyone clarify ...
Risposta accettata
Più risposte (1)
Image Analyst
il 9 Set 2023
You need to smooth the data somehow, like with movmean, movmedian, or sgolayfilt. Then once you have the "noise free signal, you can subtract and get some stats on it.
smoothSignal = movmean(signal, 9);
noiseOnly = signal - smoothSignal; % A vector
snrSignal = signal / abs(noiseOnly);
meanNoise = mean(noiseOnly); % Or use rms function.
meanSNR = mean(snrSignal);
or something similar.
7 Commenti
M
il 9 Set 2023
Image Analyst
il 9 Set 2023
Just split it up into each channel individually and process each individually. Attach your data in a .mat file if it's less than 5 MB, otherwise clip out a snippet of it to make it smaller.
M
il 9 Set 2023
Voss
il 9 Set 2023
snrSignal = signal / abs(noiseOnly);
should be
snrSignal = signal ./ abs(noiseOnly);
Image Analyst
il 10 Set 2023
Make sure both signal and smoothSignal are both either row vectors or column vectors. They're probably one of each and automatic expansion caused it to create a huge 2-D matrix.
M
il 10 Set 2023
Image Analyst
il 11 Set 2023
OK, no problem. Though the "other method" was also my method. There are several ways to smooth the data and Star and I both suggested sgolayfilt to smooth the data to get an estimate of the "noise-free" data, and then subtracting that from the signal to get an estimate of only the noise. Then compute the SNR from the ratio of the noise-free signal to the noise-only signal.
Categorie
Scopri di più su Parametric Spectral Estimation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


