DSPRelated.com
Code

Signal-to-Distortion SDR Ratio

Ron April 1, 2011 Coded in Matlab

Calculates the SDR in dB between a signal and its quantized version. The output is Y (Gamma).

[f, fs, nbits] = wavread('input.wav');
[f2, fs2, nbits2] = wavread('input-truncated.wav');

top = 1/size(f,1)*(sum(f.^2))
bottom = 1/size(f2,1)*(sum(f2.^2))

Y = 10*log10(top/bottom)