Signal to noise and distortion ratio

## Syntax

``r = sinad(x)``
``r = sinad(x,fs)``
``r = sinad(pxx,f,'psd')``
``r = sinad(sxx,f,rbw,'power')``
``````[r,totdistpow] = sinad(___)``````
``sinad(___)``

## Description

example

````r = sinad(x)` returns the signal to noise and distortion ratio (SINAD) in dBc of the real-valued sinusoidal signal `x`. The SINAD is determined using a modified periodogram of the same length as the input signal. The modified periodogram uses a Kaiser window with β = 38.```

example

````r = sinad(x,fs)` specifies the sample rate `fs` of the input signal `x`. If you do not specify `fs`, then the sample rate defaults to 1.```

example

````r = sinad(pxx,f,'psd')` specifies the input `pxx` as a one-sided power spectral density (PSD) estimate. `f` is a vector of frequencies corresponding to the PSD estimates in `pxx`.```
````r = sinad(sxx,f,rbw,'power')` specifies the input as a one-sided power spectrum. `rbw` is the resolution bandwidth over which each power estimate is integrated.```
``````[r,totdistpow] = sinad(___)``` returns the total noise and harmonic distortion power (in dB) of the signal.```

example

````sinad(___)` with no output arguments plots the spectrum of the signal in the current figure window and labels its fundamental component. It uses different colors to draw the fundamental component, the DC value, and the noise. The SINAD appears above the plot.```

## Examples

collapse all

Create two signals. Both signals have a fundamental frequency of $\pi /4$ rad/sample with amplitude 1 and the first harmonic of frequency $\pi /2$ rad/sample with amplitude 0.025. One of the signals additionally has additive white Gaussian noise with variance $0.0{5}^{2}$.

Create the two signals. Set the random number generator to the default settings for reproducible results. Determine the SINAD for the signal without additive noise and compare the result to the theoretical SINAD.

```n = 0:159; x = cos(pi/4*n)+0.025*sin(pi/2*n); rng default y = cos(pi/4*n)+0.025*sin(pi/2*n)+0.05*randn(size(n)); r = sinad(x)```
```r = 32.0412 ```
```powfund = 1; powharm = 0.025^2; thSINAD = 10*log10(powfund/powharm)```
```thSINAD = 32.0412 ```

Determine the SINAD for the sinusoidal signal with additive noise. Show how including the theoretical variance of the additive noise approximates the SINAD.

`r = sinad(y)`
```r = 22.8085 ```
```varnoise = 0.05^2; thSINAD = 10*log10(powfund/(powharm+varnoise))```
```thSINAD = 25.0515 ```

Create a signal with a fundamental frequency of 1 kHz and unit amplitude, sampled at 480 kHz. The signal additionally consists of the first harmonic with amplitude 0.02 and additive white Gaussian noise with variance $0.0{1}^{2}$.

Determine the SINAD and compare the result with the theoretical SINAD.

```fs = 48e4; t = 0:1/fs:1-1/fs; rng default x = cos(2*pi*1000*t)+0.02*sin(2*pi*2000*t)+0.01*randn(size(t)); r = sinad(x,fs)```
```r = 32.2058 ```
```powfund = 1; powharm = 0.02^2; varnoise = 0.01^2; thSINAD = 10*log10(powfund/(powharm+varnoise*(1/fs)))```
```thSINAD = 33.9794 ```

Create a signal with a fundamental frequency of 1 kHz and unit amplitude, sampled at 480 kHz. The signal additionally consists of the first harmonic with amplitude 0.02 and additive white Gaussian noise with standard deviation 0.01. Set the random number generator to the default settings for reproducible results.

Obtain the periodogram of the signal and use the periodogram as the input to `sinad`.

```fs = 48e4; t = 0:1/fs:1-1/fs; rng default x = cos(2*pi*1000*t)+0.02*sin(2*pi*2000*t)+0.01*randn(size(t)); [pxx,f] = periodogram(x,rectwin(length(x)),length(x),fs); r = sinad(pxx,f,'psd')```
```r = 32.2109 ```

Generate a sinusoid of frequency 2.5 kHz sampled at 50 kHz. Add Gaussian white noise with standard deviation 0.00005 to the signal. Pass the result through a weakly nonlinear amplifier. Plot the SINAD.

```fs = 5e4; f0 = 2.5e3; N = 1024; t = (0:N-1)/fs; ct = cos(2*pi*f0*t); cd = ct + 0.00005*randn(size(ct)); amp = [1e-5 5e-6 -1e-3 6e-5 1 25e-3]; sgn = polyval(amp,cd); sinad(sgn,fs);``` The plot shows the spectrum used to compute the ratio and the region treated as noise. The DC level and the fundamental are excluded from the noise computation. The fundamental is labeled.

## Input Arguments

collapse all

Real-valued sinusoidal input signal, specified as a row or column vector.

Example: `cos(pi/4*(0:159))+cos(pi/2*(0:159))`

Data Types: `single` | `double`

Sample rate, specified as a positive scalar. The sample rate is the number of samples per unit time. If the unit of time is seconds, then the sample rate has units of Hz.

One-sided PSD estimate, specified as a real-valued, nonnegative column vector.

The power spectral density must be expressed in linear units, not decibels. Use `db2pow` to convert decibel values to power values.

Example: `[pxx,f] = periodogram(cos(pi./[4;2]*(0:159))'+randn(160,2))` specifies the periodogram PSD estimate of a noisy two-channel sinusoid sampled at 2π Hz and the frequencies at which it is computed.

Data Types: `single` | `double`

Cyclical frequencies corresponding to the one-sided PSD estimate, `pxx`, specified as a row or column vector. The first element of `f` must be 0.

Data Types: `double` | `single`

Power spectrum, specified as a real-valued nonnegative row or column vector.

The power spectrum must be expressed in linear units, not decibels. Use `db2pow` to convert decibel values to power values.

Example: ```[sxx,w] = periodogram(cos(pi./[4;2]*(0:159))'+randn(160,2),'power')``` specifies the periodogram power spectrum estimate of a two-channel sinusoid embedded in white Gaussian noise and the normalized frequencies at which it is computed.

Resolution bandwidth, specified as a positive scalar. The resolution bandwidth is the product of the frequency resolution of the discrete Fourier transform and the equivalent noise bandwidth of the window.

## Output Arguments

collapse all

Signal to noise and distortion ratio in dBc, returned as a real-valued scalar.

Total noise and harmonic distortion power of the signal, returned as a real-valued scalar expressed in dB.

collapse 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, `sinad` 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. Higher harmonics are at integer multiples of the fundamental frequency. 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 function estimates a noise level using the median power in the regions containing only noise and distortion. The DC component is excluded from the calculation. The noise at each point is the estimated level or the ordinate of the point, whichever is smaller. The noise is then subtracted from the values of the signal and the harmonics.

`sinad` 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.

## Version History

Introduced in R2013b
{"ft_lang_label":"__label__en","ft_lang_prob":0.731035,"math_prob":0.9951685,"size":5556,"snap":"2022-40-2023-06","text_gpt3_token_len":1481,"char_repetition_ratio":0.13778819,"word_repetition_ratio":0.13727811,"special_character_ratio":0.25809935,"punctuation_ratio":0.12328767,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99885416,"pos_list":[0,1,2],"im_url_duplicate_count":[null,5,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-09-30T10:40:40Z\",\"WARC-Record-ID\":\"<urn:uuid:ab27d57e-a7ec-4116-81b3-ce4147cb06a5>\",\"Content-Length\":\"115112\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:684e20e3-2c72-4b49-96d2-929545e45f42>\",\"WARC-Concurrent-To\":\"<urn:uuid:29ba7564-e5a6-4cbb-ba6d-df83bddff81b>\",\"WARC-IP-Address\":\"104.68.243.15\",\"WARC-Target-URI\":\"https://de.mathworks.com/help/signal/ref/sinad.html\",\"WARC-Payload-Digest\":\"sha1:F5KYNG2CDZ2WDJM4X3AJYEA2GYO4BBCA\",\"WARC-Block-Digest\":\"sha1:UCGYZFZZQ6UK36MULKIXZNYYGZSPOGKM\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-40/CC-MAIN-2022-40_segments_1664030335448.34_warc_CC-MAIN-20220930082656-20220930112656-00178.warc.gz\"}"}