Thanks for such a useful tool box. I have a question of SNR calculation.
In the tool box, the function, caltulateSNR,is used to approximate in-band signal power and noise power, and then SNR is calculated. the codes are as follows:
signalBins = [f-nsig+1:f+nsig+1];
signalBins = signalBins(signalBins>0);
signalBins = signalBins(signalBins<=length(hwfft));
s = norm(hwfft(signalBins)); % *4/(N*sqrt(3)) for true rms value;
noiseBins = 1:length(hwfft);
noiseBins(signalBins) = [];
n = norm(hwfft(noiseBins));
if n==0
snr = Inf;
else
snr = dbv(s/n);
end
My question is: Since the length of signal bins and noise bins are totally different, how can signal power and noise power be substituted by
s = norm(hwfft(signalBins)) and n = norm(hwfft(noiseBins)), respectively.
I think the signal power and noise power should be like s = norm(hwfft(signalBins))*(4/N*sqrt(length(signalBins))) and n = norm(hwfft(noiseBins))*(4/N*sqrt(length(noiseBins))), respectively.
May be I'm wrong. But i'm really confused.