noisepsd
Power spectral density of filter output due to round-off noise
Syntax
Description
computes the power spectral density (PSD) of filter output occurring because of round-off
noise. The round-off noise is produced by quantization errors within the filter. The PSD is
computed as an average over the noisepsdOut
= noisepsd(sysobj
,L
)L
trials.
specifies options using one or more name-value pair arguments in addition to the input
arguments in the previous syntax.noisepsdOut
= noisepsd(___,Name=Value
)
uses an options object to specify the optional input parameters in lieu of specifying
name-value pairs.noisepsdOut
= noisepsd(sysobj
,L
,opts
)
analyzes the filter System object™ based on the arithmetic specified in the noisepsdOut
= noisepsd(sysobj
,Arithmetic=arithType
)arithType
input.
noisepsd(
with no
output argument plots the noise PSD estimate of the filter System object.sysobj
,___)
Examples
Compute the PSD of Output Noise
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. The noisepsd
function 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.
firfilt = dsp.FIRFilter with properties: Structure: 'Direct form' NumeratorSource: 'Property' Numerator: [0.0017 0.0034 -0.0049 -0.0063 0.0094 0.0125 -0.0174 -0.0226 0.0308 0.0409 -0.0576 -0.0846 0.1473 0.4488 0.4488 0.1473 -0.0846 -0.0576 0.0409 0.0308 -0.0226 -0.0174 0.0125 0.0094 -0.0063 -0.0049 0.0034 0.0017] InitialConditions: 0 Use get to show all properties
data = fi(randn(15,16),1,16,3); output = firfilt(data);
Quantize the filter to fixed-point. Plot the hpsd
data. This is the data resulting from the noise PSD calculation. You can review the data in hpsd.data
.
hpsd = noisepsd(firfilt,Arithmetic='fixed');
plot(hpsd)
Input Arguments
sysobj
— Input filter
filter System object
Input filter, specified as one of the following filter System objects:
L
— Number of trials
10
| positive integer
Number of trials used to compute the average, specified as a positive integer. The
larger you specify L, the more accurate is the estimate of power
spectral density but at the expense of longer computation time. When you do not specify
L
, the function sets L to the default value of
10 trials.
Data Types: single
| double
opts
— Options object
options object
Options object to specify the optional input parameters in lieu of specifying name-value pairs.
Create an opts
object with
opts = noisepsdopts(sysobj);
opts
then takes the noisepsd
settings from
sysobj
.
Because opts
is an object, use the set
function to change the parameter values in opts
before using it with the noisepsd
function. For example, you could
specify a new sample rate with
set(opts,NormalizedFrequency=false,Fs=48e3);
arithType
— Arithmetic type
'double'
| 'single'
| 'fixed'
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 syntax noisepsdOut = noisepsd(sysobj)
, then the
noisepsd
function applies these rules:
If the System object is
Unlocked
— Thenoisepsd
function performs double-precision analysis.If the System object is
Locked
— Thenoisepsd
function performs the analysis based on the data type of the locked input.
If you do specify the Arithmetic
argument, that is,
you use the syntax noisepsdOut =
noisepsd(sysobj,Arithmetic=
, the
arithType
)noisepsd
function applies these rules depending on the value you
set for arithType
.
Value | System Object State | Rule |
---|---|---|
arithType =
'double' | Unlocked | noisepsd performs double-precision analysis. |
Locked | noisepsd performs double-precision analysis. | |
arithType =
'single' | Unlocked | noisepsd performs single-precision analysis. |
Locked | noisepsd performs single-precision analysis. | |
arithType =
'fixed' | Unlocked | noisepsd produces an error because data type of the
fixed-point input is unknown. |
Locked | When the input data type is double or single, then noisepsd
produces an error because data type of the fixed-point input is
unknown. | |
When the input data is of fixed-point type, noisepsd
performs analysis based on the data type of the locked input. |
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is 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 enclose
Name
in quotes.
Example: b = firgr(27,[0 .4 .6 1],[1 1 0 0]); firfilt =
dsp.FIRFilter(Numerator=b); noisepsdOut = noisepsd(firfilt);
NFFT
— Number of FFT points
512 (default) | positive integer
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 the
Data
field of the noisepsdOut
structure.
When you set NFFT
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, NFFT
defaults to
512
.
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
NormalizedFrequency
— Use normalized frequency
true
(default) | false
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
.
Fs
— Sampling frequency
'Normalized'
| positive scalar
Sampling frequency to be specified in Hz when you set
NormalizedFrequency
to false
. When you set
NormalizedFrequency
to true
,
Fs
is set to 'Normalized'
.
Data Types: single
| double
SpectrumType
— Spectrum type
'Onesided'
(default) | 'Twosided'
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
.
CenterDC
— Set center of spectrum to DC
false
(default) | true
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'
tofalse
shifts 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 theSpectrumType
property setting.
Output Arguments
noisepsdOut
— PSD data object
psd
data object
Data object containing the PSD data, returned as a psd
object. To
extract the PSD vector from noisepsdOut
, enter the following in the
MATLAB® command prompt:
get(noisepsdOut,'data')
Plot the PSD data with plot(noisepsdOut)
. The average power of
the output noise (the integral of the PSD) can be computed with
avgpower
, a method of dspdata
objects:
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 R2011aR2024b: dsp.BiquadFilter
object warns
The dsp.BiquadFilter
object issues a warning and will be removed in a
future release. Use the dsp.SOSFilter
object
instead. For more information on how to replace your existing code, see the
Compatibility Considerations section in the dsp.BiquadFilter
reference page.
R2024b: Support for dsp.DCBlocker
object
Starting in R2024b, this function supports the dsp.DCBlocker
object.
R2024a: noisepsd
function no longer uses Filter Visualization Tool
When you call the noisepsd
function with no output arguments, the
function no longer uses Filter Visualization Tool to plot the power spectral density of the
filter output. Starting in R2024a, the function uses the MATLAB plot instead.
You do not need to make any changes to your code.
R2023b: dsp.BiquadFilter
object will be removed
The dsp.BiquadFilter
object will be removed in a future release. Use
the dsp.SOSFilter
object
instead.
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)