Main Content

noisepsd

Power spectral density of filter output due to roundoff noise

Description

noisepsdOut= noisepsd(sysobj,L)computes the power spectral density (PSD) of filter output occurring because of roundoff noise. The roundoff noise is produced by quantization errors within the filter. The PSD is computed as an average over theLtrials.

noisepsdOut= noisepsd(___,Name,Value)specifies options using one or more name-value pair arguments in addition to the input arguments in the previous syntax.

noisepsdOut= noisepsd(sysobj,L,opts)uses an options object to specify the optional input parameters in lieu of specifying name-value pairs.

example

noisepsdOut= noisepsd(sysobj,'Arithmetic',arithType)analyzes the filter System object™ based on the arithmetic specified in thearithTypeinput.

noisepsd(sysobj,___)with no output argument launches FVTool and shows the noise PSD estimate of the filter System object.

Examples

collapse all

Compute the PSD of the output noise caused by the quantization processes in a fixed-point, direct-form FIR filter. The input signal has fixed-point data type. Thenoisepsdfunction performs the analysis based on the data type of the locked input.

b = firgr(27,[0 .4 .6 1],[1 1 0 0]); firfilt = dsp.FIRFilter('Numerator',b);% Create the filter object.data = fi(randn(15,16),1,16,3); output = firfilt(data);

Quantize the filter to fixed-point. Plot thehpsddata. This is the data resulting from the noise PSD calculation. You can review the data inhpsd.data.

hpsd = noisepsd(firfilt,'Arithmetic','fixed'); plot(hpsd)

Figure contains an axes object. The axes object with title Power Spectral Density contains an object of type line.

Input Arguments

collapse all

Number of trials used to compute the average, specified as a positive integer. The larger you specifyL,more accurate is the estimate of power spectral density but at the expense of longer computation time. When you do not specifyL,function setsLto the default value of 10 trials.

Data Types:single|double

Options object to specify the optional input parameters in lieu of specifying name-value pairs.

Create anoptsobject with

opts = noisepsdopts(sysobj);

optsthen takes thenoisepsdsettings fromsysobj.

Becauseoptsis an object, use thesetfunction to change the parameter values inoptsbefore using it with thenoisepsdfunction. For example, you could specify a new sample rate with

set(opts,'NormalizedFrequency',false,'Fs',48e3);

Arithmetic used in the analysis, specified as'double','single', or'Fixed'. You cannot use the'Arithmetic'argument unless you know the data type of the input. If you do not specify the'Arithmetic'argument, that is, you use the syntaxnoisepsdOut = noisepsd(sysobj),n thenoisepsdfunction applies these rules:

  • If the System object isUnlocked— Thenoisepsdfunction performs double-precision analysis.

  • If the System object isLocked— Thenoisepsdfunction performs the analysis based on the data type of the locked input.

If you do specify the'Arithmetic'argument, that is, you use the syntaxnoisepsdOut = noisepsd(sysobj,'Arithmetic',arithType),noisepsdfunction applies these rules depending on the value you set forarithType.

Value System Object State Rule
arithType='double' Unlocked noisepsdperforms double-precision analysis.
Locked noisepsdperforms double-precision analysis.
arithType='single' Unlocked noisepsdperforms single-precision analysis.
Locked noisepsdperforms single-precision analysis.
arithType='fixed' Unlocked noisepsdproduces an error because data type of the fixed-point input is unknown.
Locked When the input data type is double or single, thennoisepsdproduces an error because data type of the fixed-point input is unknown.
When the input data is of fixed-point type,noisepsdperforms analysis based on the data type of the locked input.

Name-Value Arguments

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, whereNameis the argument name andValueis the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and encloseNamein quotes.

Example:b = firgr(27,[0 .4 .6 1],[1 1 0 0]); firfilt = dsp.FIRFilter('Numerator',b); noisepsdOut = noisepsd(firfilt);

Number of FFT points used in calculating the PSD, specified as a positive integer. This value determines the length of the PSD data vector shown in theDatafield of thenoisepsdOutstructure. When'NFFT'is set to an:

  • Odd integer –– The length of the PSD data is given by (NFFT+1)/2.

  • Even integer –– The length of the PSD data is given by (NFFT/2)+1.

When not specified,NFFTdefaults to512.

Note

If the spectrum data you specify is calculated over half the Nyquist interval and you do not specify a corresponding frequency vector, the default frequency vector assumes that the number of points in the whole FFT is even. Also, the plot option to convert to a whole or two-sided spectrum assumes the original whole FFT length is even.

Data Types:single|double

Indicate whether to use normalized frequency or linear frequency, specified as either:

  • true–– Use normalized frequency. When not specified, the function defaults totrue.

  • false–– Use linear frequency. When you specifyfalse, you must supply the sampling frequencyFs.

Sampling frequency to be specified in Hz when'NormalizedFrequency'is set tofalse. When'NormalizedFrequency'is set totrue,'Fs'is set to'Normalized'.

Data Types:single|double

Spectrum type of the generated PSD data, specified as:

  • 'Onesided'–– Converts the type to a spectrum that is calculated over half the Nyquist interval. All properties affected by the new frequency range are adjusted automatically.

  • 'Twosided'–– Converts the type to a spectrum that is calculated over the whole Nyquist interval. All properties affected by the new frequency range are adjusted automatically. If you choose a two-sided computation, you can also choose'CenterDC'astrue. Otherwise,'CenterDC'must befalse.

Shift the zero-frequency component to the center of a two-sided spectrum.

  • When you set'SpectrumType'to'Onesided', it is changed to'Twosided'and the data is converted to a two-sided spectrum.

  • Setting'CenterDC'tofalseshifts the data and the frequency values in the object so that DC is in the left edge of the spectrum. This operation does not affect the'SpectrumType'property setting.

Output Arguments

collapse all

Data object containing the PSD data, returned as apsdobject. To extract the PSD vector fromnoisepsdOut, enter the following in the MATLAB®command prompt:

get(noisepsdOut,'data')

Plot the PSD data withplot(noisepsdOut). The average power of the output noise (the integral of the PSD) can be computed withavgpower, a method ofdspdataobjects:

avgpwr = avgpower(hpsd)

References

[1] McClellan, James H., editor.Computer-Based Exercises for Signal Processing Using MATLAB 5. Prentice-Hall, 1998.

Version History

Introduced in R2011a

See Also

Functions