2
$\begingroup$

I am learning about SQNR and when i google i get its formula that it is equal to

6.02 db(per bit)+1.76 db

But in our Lab/class, we saw different formula ,which is following formula when using MATLAB:

SQNR=10*log10(sum(x.^2)/sum(E.^2))

Where x is original signal and E is error/noise signal

I am confused which formula is correct/proper?

Becuase if we use former formula we get different results and if we use latter formula we get different results

Based upon answer of MR Dan, i have updated my question and also included the MATLAB code we saw in our Lab

clc %clears all the text from the Command Window
clear all %clear/delete the variables created in
close all %delete all the figures whose handles are not
f=100%signal frequecny
Fs=200; %sampling frequency
Ts=1/Fs
n=4; %number of bits
L=2.^n; %quantization levels
t=0:Ts:0.1; %time interval
x=cos(2.*pi.*f.*t); %Signal x(t)
D=(max(x)-min(x))/(L-1);
xq=quant(x,D); %quantization
E=x-xq; %error calculation
SQNR=10*log10(sum(x.^2)/sum(E.^2))

$\endgroup$

1 Answer 1

1
$\begingroup$

The given formula 6.02 db(per bit)+1.76 dB is specifically that for a full scale sine wave, meaning a sine wave as big as it can be just prior to clipping. Please see this post where I detail how that is derived.

The formula you saw in your lab is correct as the SQNR for any arbitrary waveform. This should match the other formula for the case of a full scale sine wave (or similarly a cosine). If the waveform is anything else (including a lower level sine or cosine, or any other waveform), then the formula in your lab will tell you exactly what the SQNR is for that case. Your lab formula is exactly the power of the signal, divided by the power of the quantization noise, converted to dB as 10Log(power ratio). Which is what "SQNR" is.

$\endgroup$
2
  • $\begingroup$ Please check my updated question especially my code. We used a "cosine"signal in our Lab. You wrote in your answer "The formula you saw in your lab would be the SQNR for any arbitrary signal." Does that mean the formula we used in our Lab is not correct? $\endgroup$
    – sqa
    Commented Mar 1, 2023 at 5:31
  • $\begingroup$ I have checked your linked question where you are also using a formula like the one that we saw in our Lab. Your formula is also having 10Log in begining but instead of value of origianl signal you are using power of signal $\endgroup$
    – sqa
    Commented Mar 1, 2023 at 5:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.