This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

matlab code to calculate SNR,SNDR,THD SFDR

Hi all,

I want to simulate SFDR,SNR,THD and SINAD Parameter for Precision and High-Speed Series ADC TI  with Matlab.  I Need matlab code to calculate its.

 I appreciate any helps ;)

  • Hello Sina Kamar!

    Calculating SNR, THD, SFDR, and SINAD from an FFT is relatively straightforward. I do not have Matlab code for this, but here is the process, assuming you start with a complex FFT generated by Matlab. Also, I am assuming that your input frequency is "Mutually Prime Coherent" with your sample frequency, which will result in your fundamental showing up in only one bin of your FFT.

    1. For each bin of your FFT, take (the square root of the sum of the squares of the real part and the imaginary part) / (2^(2* NumberOfADCBits) to obtain a Power half-FFT. Stop the loop so that the highest bin of the FFT is the Nyquist bin. (Use something like "0 to BinCount/2 -1".)
    2. Remove the DC bin (element 0) by setting it to the minimum value of the rest of the FFT elements.

    SFDR:
    The formula is SFDR = 10 * log10( FundamentalPower / MaxSpurPower).
    MaxSpurPower is maximum power in the FFT power array that is not the fundamental. (Probably the second greatest element of the array.)

    SINAD:
    The formula is SINAD_Power = (sum of all powers in FFT array) - FundamentalPower.
    Because of crazy FFT artifacts in the FFT that occur near the zero bin and the Nyquist bin, you may want to subtract those from the result. Also, when frequencies cannot be exactly coherent (which is almost always), you may want to subtract the powers in about 3 bins on either side of the fundamental as well.
    SINAD = 10 * log10( FundamentalPower / SINAD_Power )

    THD:
    We normally consider 10 harmonics of the fundamental. (2x the fundamental, or the second harmonic, would be the first one considered. So considering 10 harmonics means harmonics 2 through 11 are considered.)
    For each harmonic, you need to know what bin it shows up in.
    1. BinNumber = (HarmonicNumber * FundamentalBin) mod NumberOfFFTbins (This finds the number of bins from the fold.)
    2. FoldCount = ConvertToInteger( (HarmonicNumber * FundamentalBin) / NumberOfFFTbins)
    3. If FoldCount is even, HarmonicBin = BinNumber.
    If FoldCount is odd, HarmonicBin = NumberOfFFTbins - BinNumber.

    Harm_Power = sum of the powers in all of the (considered) harmonic bins.
    THD = 10 * log10( Harm_Power / FundamentalPower)

    SNR:
    Noise_Power = SINAD_Power - Harm_Power
    SNR = 10 * log10( FundamentalPower / Noise_Power)

    You can use this as a guide for developing your Matlab code. Hope this helps!