Accelerating the pace of engineering and science

Documentation Center

• Trial Software

sfdr

Spurious free dynamic range

Syntax

• r = sfdr(sxx,f,pwrflag) example
• r = sfdr(sxx,f,msd,pwrflag)
• [r,spurpow,spurfreq] = sfdr(___) example

Description

example

r = sfdr(x) returns the spurious free dynamic range (SFDR), r, in dB of the real sinusoidal signal, x. sfdr computes the power spectrum using a modified periodogram and a Kaiser window with β = 38. The mean is subtracted from x before computing the power spectrum. The number of points used in the computation of the discrete Fourier transform (DFT) is the same as the length of the signal, x.

r = sfdr(x,fs) returns the SFDR of the time-domain input signal, x, when the sampling rate, fs, is specified. The default value of fs is 1 Hz.

example

r = sfdr(x,fs,msd) returns the SFDR considering only spurs that are separated from the fundamental (carrier) frequency by the minimum spur distance, msd, specified in cycles/unit time. The sampling frequency is fs. If the carrier frequency is Fc, then all spurs in the interval (Fc-msd, Fc+msd) are ignored.

example

r = sfdr(sxx,f,pwrflag) returns the SFDR of the one-sided power spectrum of a real-valued signal, sxx. f is the vector of frequencies corresponding to the power estimates in sxx. The first element of f must equal 0. The algorithm removes all the power that decreases monotonically away from the DC bin.

r = sfdr(sxx,f,msd,pwrflag) returns the SFDR considering only spurs that are separated from the fundamental (carrier) frequency by the minimum spur distance, msd. If the carrier frequency is Fc, then all spurs in the interval (Fc-msd, Fc+msd) are ignored. When the input to sfdr is a power spectrum, specifying msd can prevent high sidelobe levels from being identified as spurs.

example

[r,spurpow,spurfreq] = sfdr(___) returns the power and frequency of the largest spur.

example

sfdr(___) with no output arguments plots the spectrum of the signal in the current figure window. It uses different colors to draw the fundamental component, the DC value, and the rest of the spectrum. It shades the SFDR and displays its value above the plot. It also labels the fundamental and the largest spur.

Examples

expand all

SFDR of Sinusoid

Obtain the SFDR for a 10 MHz tone with amplitude 1 sampled at 100 MHz. There is a spur at the 1st harmonic (20 MHz) with an amplitude of 3.16 × 10–4.

```deltat = 1e-8;
t = 0:deltat:1e-6-deltat;
x = cos(2*pi*10e6*t)+3.16e-4*cos(2*pi*20e6*t);
r = sfdr(x);```

Minimum Spur Distance

Obtain the SFDR for a 10 MHz tone with amplitude 1 sampled at 100 MHz. There is a spur at the 1st harmonic (20 MHz) with an amplitude of 3.16 × 10–4. Use a minimum spur distance of 1 MHz.

```deltat = 1e-8;
fs = 1/deltat;
t = 0:deltat:1e-6-deltat;
x = cos(2*pi*10e6*t)+3.16e-4*cos(2*pi*20e6*t);
r = sfdr(x,fs,1e6);```

SFDR from Periodogram

Obtain the power spectrum of a 10 MHz tone with amplitude 1 sampled at 100 MHz. There is a spur at the 1st harmonic (20 MHz) with an amplitude of 3.16 × 10–4. Use the one-sided power spectrum and a vector of corresponding frequencies in Hz to compute the SFDR.

```deltat = 1e-8;
fs = 1/deltat;
t = 0:deltat:1e-6-deltat;
x = cos(2*pi*10e6*t)+3.16e-4*cos(2*pi*20e6*t);
[sxx,f] = periodogram(x,rectwin(length(x)),length(x),fs,'power');
r = sfdr(sxx,f,'power');```

Determine Frequency and Power of Largest Spur

Determine the frequency in MHz for the largest spur. The input signal is a 10 MHz tone with amplitude 1 sampled at 100 MHz. There is a spur at the 1st harmonic (20 MHz) with an amplitude of 3.16 × 10–4.

```deltat = 1e-8;
t = 0:deltat:1e-6-deltat;
x = cos(2*pi*10e6*t)+3.16e-4*cos(2*pi*20e6*t);
[r,spurpow,spurfreq] = sfdr(x,1/deltat);
spur_MHz = spurfreq/1e6;```

SFDR from Time Series

Create a superposition of three sinusoids, with frequencies of 9.8, 14.7, and 19.6 kHz, in white Gaussian additive noise. The signal is sampled at 44.1 kHz. The 9.8 kHz sine wave has an amplitude of 1 V, the 14.7 kHz wave has an amplitude of 100 μV, and the 19.6 kHz signal has amplitude 30 μV. The noise has 0 mean and a variance of 0.01 μV. Additionally, the signal has a DC shift of 0.1 V.

```rng default
Fs = 44.1e3;
f1 = 9.8e3;
f2 = 14.7e3;
f3 = 19.6e3;
N = 900;
nT = (0:N-1)/Fs;
x = 0.1 + sin(2*pi*f1*nT) + 100e-6*sin(2*pi*f2*nT) ...
+ 30e-6*sin(2*pi*f3*nT) + sqrt(1e-9)*randn(1,N);```

Plot the spectrum and SFDR of the signal. Display its fundamental harmonic and its largest spur.

`sfdr(x,Fs);`

The DC level is excluded from the SFDR computation.

Input Arguments

expand all

x — Real-valued sinusoidal signalrow vector | column vector

Real-valued sinusoidal signal, specified as a row or column vector. The mean is subtracted from x prior to obtaining the power spectrum for SFDR computation.

Example: x = cos(pi/4*(0:79))+1e-4*cos(pi/2*(0:79));

Data Types: double

fs — Sampling rate1 (default) | positive scalar

Sampling rate of the signal in cycles/unit time, specified as a positive scalar. When the unit of time is seconds, fs is in Hz.

Data Types: double

msd — Minimum spur distance0 (default) | positive scalar

Minimum number of discrete Fourier transform (DFT) bins to ignore in the SFDR computation, specified as a positive scalar. You can use this argument to ignore spurs or sidelobes that occur in close proximity to the fundamental frequency. For example, if the carrier frequency is Fc, then all spurs in the range (Fc-msd, Fc+msd) are ignored.

Data Types: double

sxx — One-sided power spectrumrow or column vector of positive numbers

One-sided power spectrum to use in the SFDR computation, specified as row or column vector.

Data Types: double

f — Vector of frequenciesrow or column vector of nonnegative numbers

Vector of frequencies corresponding to the power estimates in sxx, specified as a row or column vector.

pwrflag — Power spectrum input flag'power'

Flag indicating that the input is a one-sided power spectrum, sxx, specified as the string 'power'.

Output Arguments

expand all

r — Spurious free dynamic rangereal-valued scalar

Spurious free dynamic range in dB, specified as a real-valued scalar. The spurious free dynamic range is the difference in dB between the power at the peak frequency and the power at the next largest frequency (spur). If the input is time series data, the power estimates are obtained from a modified periodogram using a Hamming window. The length of the DFT used in the periodogram is equal to the length of the input signal, x. If you want to use a different power spectrum as the basis for the SFDR measurement, you can input your power spectrum using the 'power' flag.

Data Types: double

spurpow — power of largest spurreal-valued scalar

Power in dB of the largest spur, specified as a real-valued scalar.

Data Types: double

spurfreq — frequency of largest spurreal-valued scalar

Frequency in Hz of the largest spur, specified as a real-valued scalar. If you do not supply the sampling frequency as an input argument, sfdr assumes a sampling frequency of 1 Hz.

Data Types: double

expand all

Distortion Measurement Functions

The functions thd, sfdr, sinad, and snr measure the response of a weakly nonlinear system stimulated by a sinusoid.

When given time-domain input, sfdr performs a periodogram using a Kaiser window with large sidelobe attenuation. To find the fundamental frequency, the algorithm searches the periodogram for the largest nonzero spectral component. It then computes the central moment of all adjacent bins that decrease monotonically away from the maximum. To be detectable, the fundamental should be at least in the second frequency bin. If a harmonic lies within the monotonically decreasing region in the neighborhood of another, its power is considered to belong to the larger harmonic. This larger harmonic may or may not be the fundamental. The algorithm ignores all the power that decreases monotonically away from the DC bin.

sfdr fails if the fundamental is not the highest spectral component in the signal.

Ensure that the frequency components are far enough apart to accommodate for the sidelobe width of the Kaiser window. If this is not feasible, you can use the 'power' flag and compute a periodogram with a different window.