(to be removed) display frequency spectrum of time-凯发k8网页登录
(to be removed) display frequency spectrum of time-domain signals
the
dsp.spectrumanalyzer
object will be removed in a future release. use thespectrumanalyzer
matlab® object instead.the
ccdfmeasurements
property of thedsp.spectrumanalyzer
object will be removed in a future release. use thepowermeter
object instead to compute and visualize ccdf measurements.
for more information on how to replace your existing code, see compatibility considerations.
description
the spectrum analyzer system object™ displays the frequency spectrum of time-domain signals. this scope supports variable-size input, which allows the input frame size to change. frame size is the first dimension of the input vector. the number of input channels must remain constant.
to display the spectra of signals in the spectrum analyzer:
create the
dsp.spectrumanalyzer
object and set its properties.call the object with arguments, as if it were a function.
to learn more about how system objects work, see what are system objects?
creation
syntax
description
scope = dsp.spectrumanalyzer
creates a spectrum analyzer
system object. this object displays the frequency spectrum of real- and complex-valued
floating- and fixed-point signals.
scope = dsp.spectrumanalyzer(ports)
creates a spectrum analyzer
object and sets the numinputports
property to the value of
ports
.
scope = dsp.spectrumanalyzer(name,value)
sets properties using
one or more name-value pairs. enclose each property name in single quotes.
properties
unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. objects lock when you call them, and the function unlocks them.
if a property is tunable, you can change its value at any time.
for more information on changing property values, see .
frequently used
numinputports
— number of input ports
1
(default) | integer between [1, 96]
number of input ports, specified as a positive integer. each signal coming through a separate input becomes a separate channel in the scope. you must invoke the scope with the same number of inputs as the value of this property.
inputdomain
— domain of input signal
"time"
(default) | "frequency"
the domain of the input signal you want to visualize, specified as
"time"
or "frequency"
. if you visualize
time-domain signals, the spectrum analyzer transforms the signal to the frequency
spectrum based on the algorithm specified in the method
property.
scope window use
in the estimation tab on the spectrum analyzer toolstrip, set
input domain to time
or
frequency
.
data types: char
| string
spectrumtype
— spectrum type
"power"
(default) | "power density"
| "rms"
spectrum type, specified as one of these:
"power"
— power spectrum
"power density"
— power spectral density. the power spectral
density is the magnitude squared of the spectrum normalized to a bandwidth of 1
hz.
"rms"
— root mean square. the root mean square shows the square
root of the mean square. use this option to view the frequency of voltage or current
signals.
tunable: yes
dependency
to enable this property, set inputdomain
to
"time"
.
scope window use
in the analyzer tab on the spectrum analyzer toolstrip,
select spectrum. click spectrum to
select power
, power density
,
or rms
.
to enable these options, set the input
domain on the estimation tab to
time
.
data types: char
| string
viewtype
— viewer type
"spectrum"
(default) | "spectrogram"
| "spectrum and spectrogram"
specify the spectrum type as one of "spectrum"
,
"spectrogram"
, or "spectrum and spectrogram"
.
"spectrum"
— shows the power spectrum."spectrogram"
— shows frequency content over time. each line of the spectrogram is one periodogram. time scrolls from the bottom to the top of the display. the most recent spectrogram update is at the bottom of the display."spectrum and spectrogram"
— shows a dual view of a spectrum and spectrogram.
tunable: yes
scope window use
in the analyzer tab on the spectrum analyzer toolstrip, select spectrum, spectrogram, or both.
data types: char
| string
samplerate
— sample rate of input
10000
(default) | finite scalar
specify the sample rate, in hertz, of the input signals as a finite numeric scalar.
scope window use
open the spectrum settings. in the main options section, set sample rate (hz).
method
— spectrum estimation method
"filter bank"
(default) | "welch"
spectrum estimation method, specified as one of the following:
"filter bank"
–– use an analysis filter bank to estimate the power spectrum. compared to welch's method, this method has a lower noise floor, better frequency resolution, and lower spectral leakage and requires fewer samples per update."welch"
–– use welch's method of averaged modified periodograms.
for more details on these methods, see .
tunable: yes
dependency
to enable this property, set inputdomain
to
"time"
.
scope window use
in the estimation tab of the spectrum analyzer toolstrip, set
method to filter bank
or
welch
.
to enable this parameter, set input domain to
time
in the estimation
tab.
data types: char
| string
plotastwosidedspectrum
— option to plot a two-sided spectrum
true
(default) | false
option to plot a two-sided spectrum, specified as one of the following:
true
— compute and plot two-sided spectral estimates. when the input signal is complex valued, you must set this property totrue
.false
— compute and plot one-sided spectral estimates. if you set this property tofalse
, then the input signal must be real valued.when you set this property to
false
, the spectrum analyzer uses power-folding. the y-axis values are twice the amplitude that they would be if you were to set this property totrue
, except at0
and the nyquist frequency. a one-sided power spectral density (psd) contains the total power of the signal in the frequency interval from dc to half the nyquist rate. for more information, see .
tunable: yes
scope window use
click the spectrum tab or the spectrogram tab (if enabled) of the spectrum analyzer toolstrip. in the trace options section, select two-sided spectrum to compute and plot two-sided spectral estimates.
data types: logical
frequencyscale
— frequency scale
"linear"
(default) | "log"
scale to display frequency, specified as one of the following:
"linear"
— use a linear scale to display frequencies on the x-axis. to use the"linear"
setting, you must also set theplotastwosidedspectrum
property totrue
."log"
— use a logarithmic scale to display frequencies on the x-axis. to use the"log"
setting, you must also set theplotastwosidedspectrum
property tofalse
.
tunable: yes
scope window use
click the spectrum tab or the
spectrogram tab (if enabled) of the spectrum analyzer
toolstrip. in the scale section, set the frequency
scale to linear
or
log
.
to set the frequency scale to log
,
clear the two-sided spectrum check box in the trace
options section in the spectrum or the
spectrogram tab (if enabled). if you select the
two-sided spectrum check box, then you must set the
frequency scale to
linear
.
data types: char
| string
advanced
frequencyspan
— frequency span mode
"full"
(default) | "span and center frequency"
| "start and stop frequencies"
frequency span mode, specified as one of the following:
"full"
–– the spectrum analyzer computes and plots the spectrum over the entire nyquist frequency interval."span and center frequency"
–– the spectrum analyzer computes and plots the spectrum over the interval specified by thespan
andcenterfrequency
properties."start and stop frequencies"
–– the spectrum analyzer computes and plots the spectrum over the interval specified by thestartfrequency
andstopfrequency
properties.
tunable: yes
dependency
to enable this property, set inputdomain
to
"time"
.
scope window use
click the estimation tab on the spectrum analyzer toolstrip.
in the frequency options section, set frequency
span to full
, span and center
frequency
, or start and stop
frequencies
.
to enable the frequency span, set input
domain to time
.
data types: char
| string
span
— frequency span to compute spectrum
10e3
(default) | real positive scalar
specify the frequency span, in hertz, over which the spectrum analyzer computes
and plots the spectrum. the overall span, defined by this property and the
centerfrequency
property, must fall within the nyquist frequency interval.
tunable: yes
dependency
to enable this property, set frequencyspan
to
"span and center frequency"
.
scope window use
open the spectrum settings. in the main
options section, clear the full frequency span
check box and set span
.
startfrequency
— start frequency to compute spectrum
-5e3
(default) | real scalar
start of the frequency interval over which spectrum is computed, specified in
hertz as a real scalar. the overall span, which is defined by this property and
stopfrequency
, must fall within the nyquist frequency interval.
tunable: yes
dependency
to enable this property, set frequencyspan
to
"start and stop frequencies"
.
scope window use
open the spectrum settings. in the main
options section, clear the full frequency span and
change span
to fstart
. set
fstart (hz).
stopfrequency
— stop frequency to compute spectrum
5e3
(default) | real scalar
end of the frequency interval over which spectrum is computed, specified in hertz
as a real scalar. the overall span, which is defined by this property and the
startfrequency
property, must fall within the nyquist frequency interval.
tunable: yes
dependency
to enable this property, set frequencyspan
to
"start and stop frequencies"
.
scope window use
open the spectrum settings. in the main
options section, clear the full frequency span and
change span
to fstart
. set
fstop (hz).
centerfrequency
— center of frequency span
0
(default) | real scalar
specify in hertz the center frequency of the span over which the spectrum analyzer
computes and plots the spectrum. the overall frequency span, defined by the
span
and this property, must fall within the nyquist frequency interval.
tunable: yes
dependency
to enable this property, set frequencyspan
to
"span and center frequency"
.
scope window use
open the spectrum settings. in the main, clear full frequency span and set cf (hz).
frequencyresolutionmethod
— frequency resolution method
"rbw"
(default) | "windowlength"
| "numfrequencybands"
specify the frequency resolution method of the spectrum analyzer.
"rbw"
- therbwsource
andrbw
properties control the frequency resolution (in hz) of the analyzer. the fft length is the window length that results from achieving the specified rbw value or 1024, whichever is larger."windowlength"
- applies only when themethod
property is set to"welch"
. thewindowlength
property controls the frequency resolution. you can control the number of fft points only when thefrequencyresolutionmethod
property is"windowlength"
."numfrequencybands"
- applies only when themethod
property is set to"filter bank"
. thefftlengthsource
andfftlength
properties control the frequency resolution.
tunable: yes
dependency
to enable this property, set inputdomain
to
"time"
.
scope window use
open the spectrum settings. in the main options section, set the frequency resolution method by selecting the rbw (hz) dropdown.
data types: char
| string
rbwsource
— source of resolution bandwidth value
"auto"
(default) | "property"
specify the source of the resolution bandwidth (rbw) as either
"auto"
or "property"
.
"auto"
— the spectrum analyzer adjusts the spectral estimation resolution to ensure that there are 1024 rbw intervals over the defined frequency span."property"
— specify the resolution bandwidth directly using therbw
property.
tunable: yes
dependency
to enable this property, set either:
inputdomain
to"time"
andfrequencyresolutionmethod
to"rbw"
.inputdomain
to"frequency"
.
scope window use
open the spectrum settings. in the main options section, set rbw (hz).
data types: char
| string
rbw
— resolution bandwidth
9.76
(default) | real positive scalar
rbw controls the spectral resolution of spectrum analyzer. specify the resolution bandwidth in hertz as a real positive scalar. you must specify a value to ensure that there are at least two rbw intervals over the specified frequency span. thus, the ratio of the overall span to rbw must be greater than two:
you can specify the overall span in different ways based on how you
set the frequencyspan
property.
dependency
to enable, set:
rbwsource
to"property"
scope window use
open the spectrum settings. in the main options section, set rbw (hz).
windowlength
— window length
1024
(default) | integer greater than 2
control the frequency resolution by specifying the window length, in samples used to compute the spectral estimates. the window length must be an integer scalar greater than 2.
tunable: yes
dependencies
to enable this property, set:
frequencyresolutionmethod
to"windowlength"
, which controls the frequency resolution based on your window length settingmethod
to"welch"
scope window use
open the spectrum settings. change the rbw
(hz) dropdown to window length
.
fftlengthsource
— source of the fft length
"auto"
(default) | "property"
"auto"
- sets the fft length to the window length specified in thewindowlength
property or 1024, whichever is larger."property"
- number of fft points using thefftlength
property.fftlength
must be greater thanwindowlength
.
tunable: yes
dependency
to enable this property, set frequencyresolutionmethod
to
"windowlength"
.
scope window use
open the spectrum settings. in the main options section, next to the rbw (hz) option, enter
a number or select auto
.
data types: char
| string
fftlength
— length of fft
1024
(default) | positive integer
specify the length of the fft that the spectrum analyzer uses to compute spectral estimates.
if frequencyresolutionmethod
is "rbw"
, the
fft length is set as the window length required to achieve the specified resolution
bandwidth value or 1024, whichever is larger.
tunable: yes
dependencies
to use this property, the following must be true:
frequencyresolutionmethod
is set to"windowlength"
or"numfrequencybands"
fftlength
is greater than or equal to thewindowlength
.fftlengthsource
is set to"property"
.
scope window use
open the spectrum settings. in the main
options section, next to the rbw (hz) option,
enter a number or select auto
.
numtapsperband
— number of filter taps per frequency band
12
(default) | positive even scalar
specify the number of filter taps or coefficients for each frequency band. this
number must be a positive even integer. this value corresponds to the number of filter
coefficients per polyphase branch. the total number of filter coefficients is equal to
numtapsperband
fftlength
.
dependency
to enable this property, set method
to "filter
bank"
scope window use
open the spectrum settings. in the main options section, set taps per band.
frequencyvectorsource
— source of frequency vector
"auto"
(default) | "property"
"auto"
— the frequency vector is calculated from the length of the input. see frequency vector."property"
— enter a custom vector as the frequency vector.
dependency
to enable this property, set inputdomain
to
"frequency"
.
scope window use
open the spectrum settings. in the frequency input options section, set frequency (hz).
data types: char
| string
frequencyvector
— custom frequency vector
[-5000 5000]
(default) | monotonically increasing vector
custom frequency vector, specified as a monotonically increasing vector. this vector determines the x-axis of the display. the vector must be monotonically increasing and must have the same length as the input signal frame size.
tunable: yes
dependency
to enable this property, set:
inputdomain
to"frequency"
.frequencyvectorsource
to"property"
.
to .
scope window use
click the estimation tab on the spectrum analyzer toolstrip. in the domain section, set frequency (hz) to a monotonically increasing vector of length equal to the input signal frame size.
to enable the frequency (hz), set input domain
to frequency
.
data types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
overlappercent
— overlap percentage
0
(default) | real, scalar value
the percentage overlap between the previous and current buffered data segments, specified as a real, scalar value. the overlap creates a window segment that is used to compute a spectral estimate. the value must be greater than or equal to zero and less than 100.
tunable: yes
scope window use
open the spectrum settings. in the window options section, set overlap (%).
window
— window function
"hann"
(default) | "rectangular"
| "chebyshev"
| "flat top"
| "hamming"
| "kaiser"
| "blackman-harris"
| "custom"
specify a window function for the spectral estimator. the following table shows preset windows. for more information, follow the link to the corresponding function reference in the signal processing toolbox™ documentation.
window option | corresponding signal processing toolbox function |
---|---|
"rectangular" | |
"chebyshev" | |
"flat top" | |
"hamming" | |
"hann" | |
"kaiser" | |
"blackman-harris" |
to set your own spectral estimation window, set this property to
"custom"
and specify a custom window function in the customwindow
property.
tunable: yes
dependency
to enable this property, set:
inputdomain
to"time"
.method
to"welch"
scope window use
click the estimation tab on the spectrum analyzer toolstrip. in the window options section, set the window.
to enable the window, set input domain
to time
and method to
welch
in the estimation tab on
the spectrum analyzer toolstrip.
data types: char
| string
customwindow
— name of custom window function
"hann"
(default) | character vector | string scalar
name of the custom window function, specified as a character vector or string scalar. the name of the custom window function must be on the matlab path. use this property if you want to customize the window using additional properties available with the signal processing toolbox version of the window function.
tunable: yes
example
define and use a custom window function.
function w = my_hann(l) w = hann(l, 'periodic') end scope.window = 'custom'; scope.customwindow = 'my_hann'
dependency
to use this property, set window
to
"custom"
.
scope window use
click the estimation tab on the spectrum analyzer toolstrip. in the window options section, for the window, enter the name of the custom window function.
data types: char
| string
sidelobeattenuation
— sidelobe attenuation of window
60
(default) | real positive scalar
the window sidelobe attenuation, in decibels (db). the value must be greater than
or equal to 45
.
tunable: yes
dependency
to enable this property, set window
to
"chebyshev"
or "kaiser"
.
scope window use
open the spectrum settings. in the window options section, set attenuation (db).
inputunits
— units of frequency input
"dbm"
(default) | "dbv"
| "dbw"
| "vrms"
| "watts"
select the units of the frequency-domain input. this property allows the spectrum
analyzer to scale frequency data if you choose a different display unit with the
spectrumunits
property.
dependency
this option is only available when inputdomain
is set to
frequency
.
scope window use
open the spectrum settings. in the frequency input options section, set input units.
data types: char
| string
spectrumunits
— units of the spectrum
"dbm"
(default) | "dbfs"
| "dbv"
| "dbw"
| "vrms"
| "watts"
| "dbm/hz"
| "dbw/hz"
| "dbfs/hz"
| "watts/hz"
| "auto"
specify the units in which the spectrum analyzer displays power values.
tunable: yes
dependency
the spectrum units available depend on the value you specify in the
spectrumtype
property.
inputdomain | spectrumtype | allowed
spectrumunits |
---|---|---|
"time" | "power" | "dbm" , "dbw" ,
"dbfs" ,
"watts" |
"power density" | "dbm/hz" ,
"dbw/hz" ,"dbfs/hz" ,
"watts/hz" | |
"rms" | "dbv" , "vrms" | |
"frequency" | ― | "auto" ,
"dbm" , "dbv" ,
"dbw" , "vrms" ,
"watts" |
if you set the inputdomain
property to
"frequency"
and the spectrumunits
property to "auto"
, the spectrum analyzer assumes the spectrum
units to be equal to input units specified in the inputunits
property. if you set inputdomain
to "time"
and spectrumunits
to any option other than
"auto"
, then the spectrum analyzer converts the units
specified in inputunits
to the units specified in
spectrumunits
.
scope window use
click the spectrum tab on the spectrum analyzer toolstrip. in the scale section, set spectrum unit.
data types: char
| string
fullscalesource
— source of full scale
"auto"
(default) | "property"
specify the source of the dbfs scaling factor as either "auto"
or
"property"
.
"auto"
–– the spectrum analyzer adjusts the scaling factor based on the input data."property"
–– specify the full-scale scaling factor using thefullscale
property.
tunable: yes
dependency
to enable this property, set:
inputdomain
to"time"
spectrumtype
to"power"
or"power density"
spectrumunits
to"dbfs"
or"dbfs/hz"
(when spectrum type is set to"power density"
)
scope window use
click the spectrum tab on the spectrum analyzer toolstrip. in
the scale section, set the full scale to
either auto
or a positive scalar.
to enable the full scale:
in the analyzer tab, set the spectrum type to
power
orpower density
.in the estimation tab, set input domain to
time
.in the spectrum tab, set spectrum unit to
dbfs
ordbfs/hz
(when spectrum type is set topower density
).
data types: char
| string
fullscale
— full scale
1
(default) | positive scalar
specify a real positive scalar for the dbfs
full scale.
tunable: yes
dependency
to enable this option set:
spectrumunits
to"dbfs"
fullscalesource
to"property"
scope window use
open the spectrum settings. in the trace
options section, set full scale to
auto
or enter a number.
averagingmethod
— smoothing method
"vbw"
(default) | "exponential"
averaging method, specified as one of the following:
"vbw"
— video bandwidth method. the object uses a lowpass filter to smooth the trace and decrease noise. use thevbwsource
andvbw
properties to specify the vbw value."exponential"
— weighted average of samples. the object computes the average over samples weighted by an exponentially decaying forgetting factor. use theforgettingfactor
property to specify the weighted forgetting factor.
for more information, see .
tunable: yes
dependency
to enable this property, set inputdomain
to
"time"
.
scope window use
click the estimation tab on the spectrum analyzer
toolstrip. in the averaging section, set
averaging method to
vbw
or
exponential
.
to enable the averaging method, set
input domain to
time
.
data types: char
| string
spectralaverages
— number of spectral averages
1
(default) | positive integer
the spectrum analyzer computes the current power spectrum estimate by computing a running average of the last n power spectrum estimates. this property defines n.
tunable: yes
dependency
to enable this property, set viewtype
to
"spectrum"
.
dependency
this property applies only when the averagingmethod
is
"running"
.
scope window use
open the spectrum settings. in the trace options section, set averages.
forgettingfactor
— weighting forgetting factor
0.9
(default) | scalar in the range (0,1]
specify the exponential weighting as a scalar value greater than 0 and less than or equal to 1.
dependency
this property applies only when the averagingmethod
is
"exponential"
.
scope window use
open the spectrum settings. in the trace options section, set forgetting factor.
referenceload
— reference load
1
(default) | real positive scalar
the load the scope uses as a reference to compute power levels.
tunable: yes
scope window use
open the spectrum settings. in the trace options section, set ref. load (ohms).
frequencyoffset
— frequency offset
0
(default) | scalar | vector
scalar — apply the same frequency offset to all channels, specified in hertz as a character vector.
vector — apply a specific frequency offset for each channel, specify a vector of frequencies. the vector length must be equal to number of input channels.
the frequency-axis values are offset by the values specified in this property. the overall span must fall within the nyquist frequency interval. you can control the overall span in different ways based on how you set the
frequencyspan
property.
tunable: yes
scope window use
open the spectrum settings. in the trace options section, set offset (hz).
spectrogram
spectrogramchannel
— channel for which spectrogram is plotted
1
(default) | positive scalar integer
specify the channel for which the spectrogram is plotted, as a real, positive scalar integer in the range [1 n], where n is the number of input channels.
tunable: yes
dependency
to enable this property, set viewtype
to
"spectrogram"
or "spectrum and
spectrogram"
.
scope window use
open the spectrum settings. in the spectrogram options section, select a channel.
timeresolutionsource
— source of the time resolution value
"auto"
(default) | "property"
specify the source for the time resolution of each spectrogram line as either
"auto"
or "property"
. the timeresolution
property shows the time resolution for the different
frequency resolution methods and time resolution properties.
tunable: yes
dependency
to enable this property, set viewtype
to
"spectrogram"
or "spectrum and
spectrogram"
.
scope window use
click the spectrogram tab on the spectrum analyzer toolstrip.
in the time options section, set the time resolution
(s) to auto
or enter a positive scalar.
to enable the time resolution (s), select spectrogram in the analyzer tab.
data types: char
| string
timeresolution
— time resolution
0.001
(default) | positive scalar
specify the time resolution of each spectrogram line as a positive scalar, expressed in seconds.
the spectrum analyzer determines the time resolution value based on the frequency resolution method, rbw, and time resolution properties.
method | rbw | time resolution | resulting time resolution in seconds |
---|---|---|---|
welch or filter
bank | auto | auto | 1/rbw |
welch or filter
bank | auto | manually entered | 1/time resolution hz |
welch or filter
bank | manually entered | auto | 1/rbw seconds |
welch or filter
bank | manually entered | manually entered | equal to or greater than the minimum attainable time resolution 1/rbw. the spectrum analyzer combines several spectral estimates into one spectrogram line to obtain the desired time resolution. it uses interpolation to obtain time resolution values that are not integer multiples of 1/rbw. |
tunable: yes
dependency
to enable this property, set:
viewtype
to"spectrogram"
or"spectrum and spectrogram"
timeresolutionsource
to"property
.
scope window use
open the spectrum settings. in the spectrogram options section, in the time res (s) box, enter a number.
timespansource
— source of time span value
"auto"
(default) | "property"
source for the time span of the spectrogram, specified as either
"auto"
or "property"
. if you set this property
to "auto"
, the spectrogram displays 100 spectrogram lines at any
given time. if you set this property to "property"
, the spectrogram
uses the time duration you specify in seconds in the timespan
property.
tunable: yes
dependency
to enable this property, set viewtype
to
"spectrogram"
or "spectrum and
spectrogram"
.
scope window use
click the spectrogram tab on the spectrum analyzer toolstrip.
in the time options section, set the time span
(s) to auto
or enter a positive scalar.
data types: char
| string
timespan
— time span
0.1
(default) | positive scalar
specify the time span of the spectrogram display in seconds. you must set the time span to be at least twice as large as the duration of the number of samples required for a spectral update.
tunable: yes
dependency
to enable this property, set:
viewtype
to"spectrogram"
or"spectrum and spectrogram"
.timespansource
to"property"
.
scope window use
open the spectrum settings. in the spectrogram options section, in the time span (s) box, enter a number.
measurements
measurementchannel
— channel for which measurements are obtained
1
(default) | positive integer
channel for which the measurements are obtained, specified as a real, positive integer greater than 0 and less than or equal to 100. the maximum number you can specify is the number of channels (columns) in the input signal.
tunable: yes
scope window use
click on tools > measurements and open the trace selection settings.
data types: double
spectralmask
— spectral mask lines
spectralmaskspecification
object
specify whether to display upper and lower spectral mask lines on a spectrum plot. this property uses properties from a object to enable and configure the spectral masks.
tunable: yes
scope window use
open the spectral mask pane and modify the settings options.
peakfinder
— peak finder measurement
peakfinderconfiguration
object
peak finder measurement, specified as a object. enable peak finder to compute and display
the largest calculated peak values. all peakfinderconfiguration
properties are tunable.
tunable: yes
dependency
to enable this property, set viewtype
to
"spectrum"
or "spectrum and
spectrogram"
.
scope window use
click the measurements tab on the spectrum analyzer toolstrip and modify the peak finder measurements in the peaks section.
the measurements tab appears when you select spectrum in the analyzer tab.
cursormeasurements
— cursor measurements
cursormeasurementsconfiguration
object
cursor measurements, specified as a
object. enable cursor measurements to display waveform cursors. all
cursormeasurementsconfiguration
properties are
tunable.
tunable: yes
dependency
to enable this property, set viewtype
to "spectrum"
or
"spectrum and spectrogram"
.
scope window use
click the measurements tab on the spectrum analyzer toolstrip and modify the cursor measurements in the cursors section.
the measurements tab appears when you select spectrum in the analyzer tab.
channelmeasurements
— channel measurements
channelmeasurementsspecification
object
enable channel measurements to compute and display the occupied bandwidth or adjacent channel power ratio. the channelmeasurements
property uses the channelmeasurementsspecification
properties.
the channelmeasurementsspecification
properties are:
algorithm
–– type of measurement data to display, specified as either"occupied bw"
or"acpr"
.default:
"occupied bw"
frequencyspan
–– frequency span mode, specified as either"span and center frequency"
or"start and stop frequencies"
default:
"span and center frequency"
span
–– frequency span over which the channel measurements are computed, specified as a real, positive scalar in hz. this property applies when you set thefrequencyspan
property to"span and center frequency"
.default:
2000
hzcenterfrequency
–– center frequency of the span over which the channel measurements are computed, specified as a real scalar in hz. this property applies when you set thefrequencyspan
property to"span and center frequency"
.default:
0
hzstartfrequency
–– start frequency over which the channel measurements are computed, specified as a real scalar in hz. this property applies when you set thefrequencyspan
property to"start and stop frequencies"
.default:
-1000
hzstopfrequency
–– stop frequency over which the channel measurements are computed, specified as a real scalar in hz. this property applies when you set thefrequencyspan
property to"start and stop frequencies"
.default:
1000
hzpercentoccupiedbw
–– percent of power over which to compute the occupied bandwidth, specified as a positive real scalar. this property applies when you set thealgorithm
property to"occupied bw"
.default:
99
numoffsets
–– number of adjacent channel pairs, specified as a real, positive integer. this property applies when you set thealgorithm
property to"acpr"
.default:
2
adjacentbw
–– adjacent channel bandwidth, specified as a real, positive scalar. this property applies when you set thealgorithm
property to"acpr"
.default:
1000
filtershape
–– filter shape for both main and adjacent channels, specified as"none"
,"gaussian"
, or"rrc"
. this property applies when you set thealgorithm
property to"acpr"
.default:
"none"
filtercoeff
–– channel filter coefficient, specified as a real scalar between0
and1
. this property applies when you set thealgorithm
property to"acpr"
and thefiltershape
property to either"gaussian"
or"rrc"
.default:
0.5
acproffsets
–– frequency of the adjacent channel relative to the center frequency of the main channel, specified as a real vector of length equal to the number of offset pairs specified innumoffsets
. this property applies when you set thealgorithm
property to"acpr"
.default:
[2000 3500]
enable
–– set this property totrue
to enable channel measurements. valid values aretrue
orfalse
.default:
false
all channelmeasurementsspecification
properties are tunable.
scope window use
open the channel measurements pane () and modify the measurement and channel settings options.
distortionmeasurements
— distortion measurements
distortionmeasurementsconfiguration
object
distortion measurements, specified as a object. enable distortion measurements
to compute and display the harmonic distortion and intermodulation distortion. all
distortionmeasurementsconfiguration
properties are tunable.
tunable: yes
dependency
to enable this property, set viewtype
to "spectrum"
or
"spectrum and spectrogram"
.
scope window use
click the measurements tab on the spectrum analyzer toolstrip and modify the distortion measurements in the distortion section.
the measurements tab appears when you select spectrum in the analyzer tab.
visualization
name
— caption to display in spectrum analyzer window
"spectrum analyzer"
(default) | character vector | string scalar
caption to display in the scope window, specified as a character vector or string scalar.
tunable: yes
data types: char
| string
position
— window position
screen center (default) | [left bottom width height]
spectrum analyzer window position in pixels, specified by the size and location of the scope window as a four-element double vector of the form [left bottom width height]. you can place the scope window in a specific position on your screen by modifying the values to this property.
by default, the window appears in the center of your screen with a width of 800
pixels and height
of 450
pixels. the exact center coordinates depend on your screen resolution.
tunable: yes
plottype
— plot type to display normal traces
"line"
(default) | "stem"
plot type to display normal traces, specified as "line"
or
"stem"
. normal traces are traces that display free-running
spectral estimates.
tunable: yes
dependencies
to enable this property, set:
viewtype
to"spectrum"
or"spectrum and spectrogram"
.plotnormaltrace
totrue
.
scope window use
click the analyzer tab on the spectrum analyzer toolstrip,
navigate to the configuration section and click
settings. in the spectrum analyzer settings window, under
display and labels, set plot type to
line
or stem
.
to enable the plot type, you must:
select spectrum in the views section of the analyzer tab.
enable the normal trace check box in the trace options section of the spectrum tab.
data types: char
| string
plotnormaltrace
— normal trace flag
true
(default) | false
to remove normal traces from the display, set this property to
false
. these traces display the free-running spectral estimates.
the spectrum analyzer continues its spectral computations even when you set this
property to false
.
tunable: yes
dependency
to enable this property, set viewtype
to
"spectrum"
or "spectrum and
spectrogram"
.
scope window use
click the spectrum tab on the spectrum analyzer toolstrip and select the normal trace check box in the trace options section.
to enable the normal trace check box, select spectrum in the analyzer tab.
data types: logical
plotmaxholdtrace
— max-hold trace flag
false
(default) | true
to compute and plot the maximum-hold spectrum of each input channel, set this property to true
.
the maximum-hold spectrum at each frequency bin is computed by keeping the maximum value of all the power spectrum
estimates. when you toggle this property, the spectrum analyzer resets its maximum-hold computations.
tunable: yes
dependency
to enable this property, set viewtype
to
"spectrum"
or "spectrum and
spectrogram"
.
scope window use
click the spectrum tab on the spectrum analyzer toolstrip and select the max-hold trace check box in the trace options section.
to enable the max-hold trace check box, select spectrum in the analyzer tab.
data types: logical
plotminholdtrace
— min-hold trace flag
false
(default) | true
to compute and plot the minimum-hold spectrum of each input channel, set this property to true
.
the minimum-hold spectrum at each frequency bin is computed by keeping the minimum value of all the power spectrum
estimates. when you toggle this property, the spectrum analyzer resets its minimum-hold computations.
tunable: yes
dependency
to enable this property, set viewtype
to
"spectrum"
or "spectrum and
spectrogram"
.
scope window use
click the spectrum tab on the spectrum analyzer toolstrip and select the min-hold trace check box in the trace options section.
to enable the min-hold trace check box, select spectrum in the analyzer tab.
data types: logical
title
— display title
''
(default) | character vector | string scalar
display title, specified as a character vector or a string scalar.
tunable: yes
scope window use
click the analyzer tab on the spectrum analyzer toolstrip. in the configuration section, click settings. in the spectrum analyzer settings window that opens up, under display and labels, enter title.
data types: char
| string
ylabel
— y-axis label
''
(default) | character vector | string scalar
y-axis label, specified as a character vector or a string scalar. the spectrum analyzer displays the label to the left of the y-axis.
regardless of the value of this property, spectrum analyzer always displays power
units as one of the spectrumunits
values.
tunable: yes
dependency
to enable this property, set viewtype
to
"spectrum"
or "spectrum and
spectrogram"
.
scope window use
click the analyzer tab on the spectrum analyzer toolstrip. in the configuration section, click settings. in the spectrum analyzer settings window that opens up, under display and labels, enter y-label.
to enable the y-label, select spectrum in the analyzer tab.
data types: char
| string
showlegend
— flag to show legend
false
(default) | true
flag to show the legend, specified as true
or
false
. to show a legend with the input names, set this property
to true
.
use the legend to control which signals are visible. in the scope legend, click a signal name to hide the signal in the scope. to show the signal, click the signal name again. to show only one signal, right-click the signal name. to show all signals, press esc.
tunable: yes
dependencies
to enable this property, set the viewtype
property to
"spectrum"
or "spectrum and spectrogram"
.
scope window use
click the analyzer tab on the spectrum analyzer toolstrip. to see the legend, click legend in the configuration section.
to enable the legend, select spectrum in the analyzer tab.
data types: logical
channelnames
— channel names
empty cell (default) | cell array of character vectors | array of strings
channel names in the input data, specified as a cell array of character vectors or an array of strings. the names you specify in this property appear in the following locations:
legend
spectrum analyzer settings > color and styling section
measurements and channel measurements tabs
if you do not specify channel names, the
spectrum analyzer names the channels as channel 1
, channel
2
, and so on.
tunable: yes
dependency
to see the channel names, set showlegend
to
true
.
scope window use
click the analyzer tab on the spectrum analyzer toolstrip. to see the legend, click legend in the configuration section.
data types: char
showgrid
— flag to show grid
true
(default) | false
flag to show the grid, specified as true
or
false
. set this property to true
to show grid
lines in the plot.
tunable: yes
scope window use
click the analyzer tab on the spectrum analyzer toolstrip. in the configuration section, click settings. in the spectrum analyzer settings window that appears, under display and labels, select show grid.
data types: logical
ylimits
— y-axis limits
[-80, 20]
(default) | [ymin ymax]
y-axis limits, specified as a two-element numeric vector of the
form [ymin ymax
]. the units of the y-axis limits
depend on the spectrumunits
property.
example: scope.ylimits = [-10,20]
tunable: yes
dependencies
to enable this property, set the
viewtype
property to"spectrum"
or"spectrum and spectrogram"
.the units directly depend upon the
spectrumunits
property.
scope window use
click the analyzer tab on the spectrum analyzer toolstrip. in the configuration section, click settings. in the spectrum analyzer settings window that opens up, under display and labels, enter y-axis limits.
to enable the y-axis limits, select spectrum in the analyzer tab.
colorlimits
— scale spectrogram color limits
[-80, 20]
(default) | [colormin colormax]
color limits of the spectrogram, specified as a two-element numeric vector of the form
[colormin colormax
]. the units of the color limits directly
depend upon the spectrumunits
property.
example: scope.colorlimits = [-10,20]
tunable: yes
dependencies
to enable this property, set the
viewtype
property to"spectrogram"
or"spectrum and spectrogram"
.the units directly depend upon the
spectrumunits
property.
scope window use
click the analyzer tab on the spectrum analyzer toolstrip. in the configuration section, click settings. in the spectrum analyzer settings window that opens up, under display and labels, enter color limits.
to enable the color limits, select spectrogram in the analyzer tab.
axesscaling
— axes scaling mode
"auto"
(default) | "manual"
| "onceatstop"
| "updates"
axes scaling mode, specified as one of these:
"auto"
— the scope scales the axes to fit the data, both during and after simulation."manual"
— the scope does not scale the axes automatically."onceatstop"
— the scope scales the axes when the simulation stops."updates"
— the scope scales the axes after a specific number of visual updates. it determines the number of updates using theaxesscalingnumupdates
property.
tunable: yes
data types: char
| string
axeslayout
— orientation of the spectrum and spectrogram
"vertical"
(default) | "horizontal"
layout of the axes, specified as one of "vertical"
or
"horizontal"
. a vertical layout stacks the spectrum above the
spectrogram. a horizontal layout puts the two views side-by-side.
tunable: yes
dependency
to enable this property, set viewtype
to "spectrum
and spectrogram"
.
scope window use
click the analyzer tab on the spectrum analyzer toolstrip. select spectrum and spectrogram. in the configuration section, select and update layout.
data types: char
| string
usage
description
scope(
updates the spectrum of the
signal in the spectrum analyzer.signal
)
scope(signal1,signal2,...,signaln)
displays multiple signals in
the spectrum analyzer. the signals must have the same frame length, but can vary in number
of channels. you must set the numinputports
property to enable
multiple input signals.
input arguments
signal
— input signal or signals to visualize
scalar | vector | matrix
specify one or more input signals to visualize in the
dsp.spectrumanalyzer
. signals can have a different number of channels, but
must have the same frame length.
example: scope(signal1, signal2)
data types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
object functions
to use an object function, specify the
system object as the first input argument. for
example, to release system resources of a system object named obj
, use
this syntax:
release(obj)
specific to dsp.spectrumanalyzer
generate matlab script to create scope with current settings | |
get the current measurement data displayed on the spectrum analyzer | |
get test results of current spectral mask | |
save spectrum data shown in spectrum analyzer | |
check spectrum analyzer for new data |
specific to scopes
display scope window | |
hide scope window | |
determine visibility of scope |
common to all system objects
run system object algorithm | |
release resources and allow changes to system object property values and input characteristics | |
reset internal states of system object |
if you want to restart the simulation from the beginning, call reset
to
clear the scope window displays. do not call reset
after calling
release
.
examples
spectrum analyzer for one-sided power spectrum
view a one-sided power spectrum made from the sum of fixed real sine waves with different amplitudes and frequencies.
fs = 100e6; % sampling frequency fsz = 5000; % frame size sin1 = dsp.sinewave(1e0, 5e6,0,'samplesperframe',fsz,'samplerate',fs); sin2 = dsp.sinewave(1e-1,15e6,0,'samplesperframe',fsz,'samplerate',fs); sin3 = dsp.sinewave(1e-2,25e6,0,'samplesperframe',fsz,'samplerate',fs); sin4 = dsp.sinewave(1e-3,35e6,0,'samplesperframe',fsz,'samplerate',fs); sin5 = dsp.sinewave(1e-4,45e6,0,'samplesperframe',fsz,'samplerate',fs); scope = dsp.spectrumanalyzer; scope.samplerate = fs; scope.spectralaverages = 1; scope.plotastwosidedspectrum = false; scope.rbwsource = 'auto'; scope.powerunits = 'dbw'; for idx = 1:1e2 y1 = sin1(); y2 = sin2(); y3 = sin3(); y4 = sin4(); y5 = sin5(); scope(y1 y2 y3 y4 y5 0.0001*randn(fsz,1)); end
run the release
method to let property values and input
characteristics change. the scope automatically scales the axes.
release(scope)
run the clear
function to close the spectrum analyzer
window.
clear('scope');
spectrum analyzer for two-sided power spectrum
view a two-sided power spectrum of a sine wave with noise on the spectrum analyzer.
sin = dsp.sinewave('frequency',100,'samplerate',1000); sin.samplesperframe = 1000; scope = dsp.spectrumanalyzer('samplerate',sin.samplerate); for ii = 1:250 x = sin() 0.05*randn(1000,1); scope(x); end
run the release
method to change property values and input
characteristics. the scope automatically scales the axes. it updates the display one
more time if any data is in the internal buffer.
release(scope);
run the matlab clear
function to close the spectrum analyzer
window.
clear('scope');
spectrogram of chirp signal
this example shows the spectrogram for a chirp signal with added random noise.
fs = 233e3; framesize = 20e3; chirp = dsp.chirp('samplerate',fs,... 'samplesperframe',framesize,... 'initialfrequency',11e3,... 'targetfrequency',11e3 55e3); scope = dsp.spectrumanalyzer('samplerate',fs); scope.viewtype = 'spectrogram'; scope.rbwsource = 'property'; scope.rbw = 500; scope.timespansource = 'property'; scope.timespan = 2; scope.plotastwosidedspectrum = false; for idx = 1:50 y = chirp() 0.05*randn(framesize,1); scope(y); end release(scope)
display frequency input from spectral estimation
use the spectrum analyzer to display frequency input from spectral estimates of sinusoids embedded in white gaussian noise.
initialization
initialize two dsp.spectrumestimator
objects to display. set one
object to use the welch-based spectral estimation technique with a hann window, set the
other object use a filter bank estimation. specify a noisy sine wave input signal with
four sinusoids at 0.16, 0.2, 0.205, and 0.25 cycles/sample. view the spectral estimate
using a third object, a spectrum analyzer, set to process frequency input.
framesize = 420; fs = 1; frequency = [0.16 0.2 0.205 0.25]; sinegen = dsp.sinewave('samplerate',fs,'samplesperframe',framesize,... 'frequency',frequency,'amplitude',[2e-5 1 0.05 0.5]); noisevar = 1e-10; numavgs = 8; hannestimator = dsp.spectrumestimator('powerunits','dbm',... 'window','hann','frequencyrange','onesided',... 'spectralaverages',numavgs,'samplerate',fs); filterbankestimator = dsp.spectrumestimator('powerunits','dbm',... 'method','filter bank','frequencyrange','onesided',... 'spectralaverages',numavgs,'samplerate',fs); spectrumplotter = dsp.spectrumanalyzer('inputdomain','frequency',... 'samplerate',fs,... 'spectrumunits','dbm','ylimits',[-120,40],... 'plotastwosidedspectrum',false,... 'channelnames',{'hann window','filter bank'},'showlegend',true);
streaming
stream the input. compare the spectral estimates in the spectrum analyzer.
for i = 1:1000 x = sum(sinegen(),2) sqrt(noisevar)*randn(framesize,1); pse_hann = hannestimator(x); pfb = filterbankestimator(x); spectrumplotter([pse_hann,pfb]) end
obtain measurement data programmatically for dsp.spectrumanalyzer
system object
compute and display the power spectrum of a noisy sinusoidal input
signal using the dsp.spectrumanalyzer
system object. measure the peaks, cursor placements, adjacent channel power ratio, and
distortion in the spectrum by enabling the following properties:
peakfinder
cursormeasurements
channelmeasurements
distortionmeasurements
initialization
the input sine wave has two frequencies: 1000 hz and 5000 hz. create two
dsp.sinewave
system objects to generate these two frequencies.
create a dsp.spectrumanalyzer
system object to compute and display
the power spectrum.
fs = 44100; sineobject1 = dsp.sinewave('samplesperframe',1024,... 'phaseoffset',10,... 'samplerate',fs,'frequency',1000); sineobject2 = dsp.sinewave('samplesperframe',1024,... 'samplerate',fs,'frequency',5000); sa = dsp.spectrumanalyzer('samplerate',fs,'method','filter bank',... 'spectrumtype','power','plotastwosidedspectrum',false,... 'channelnames',{'power spectrum of the input'},... 'ylimits',[-120 40],'showlegend',true);
enable measurements data
to obtain the measurements, set the enable
property of the
measurements to true
.
sa.cursormeasurements.enable = true; sa.channelmeasurements.enable = true; sa.peakfinder.enable = true; sa.distortionmeasurements.enable = true;
use getmeasurementsdata
stream in the noisy sine wave input signal and estimate the power spectrum of the
signal using the spectrum analyzer. measure the characteristics of the spectrum. use the
getmeasurementsdata
function to obtain these measurements
programmatically. the isnewdataready
function indicates when there is
new spectrum data. the measured data is stored in the variable
data
.
data = []; for iter = 1:1000 sinewave1 = sineobject1(); sinewave2 = sineobject2(); input = sinewave1 sinewave2; noisyinput = input 0.001*randn(1024,1); sa(noisyinput); if sa.isnewdataready data = [data;getmeasurementsdata(sa)]; end end
the right side of the spectrum analyzer shows the enabled measurement panes. the
values shown in these panes match with the values shown in the last time step of the
data
variable. you can access the individual fields of
data
to obtain the various measurements programmatically.
compare peak values
peak values are obtained by the peakfinder
property. verify that
the peak values obtained in the last time step of data
match the
values shown on the spectrum analyzer plot.
peakvalues = data.peakfinder(end).value
peakvalues = 3×1
26.9851
24.1735
-51.1973
frequencieskhz = data.peakfinder(end).frequency/1000
frequencieskhz = 3×1
4.9957
0.9905
0.2369
tips
to close the scope window and clear its associated data, use the matlab function.
to hide or show the scope window, use the and functions.
use the matlab
mcc
function to compile code containing a spectrum analyzer.you cannot open spectrum analyzer configuration dialog boxes if you have more than one compiled component in your application.
algorithms
spectrum estimation — filter bank
when you choose the filter bank
method, the spectrum
analyzer uses an analysis filter bank to estimate the power spectrum.
the filter bank splits the broadband input signal x(n), of sample rate fs, into multiple narrow band signals y0(m), y1(m), … , ym-1(m), of sample rate fs/m.
the variable m represents the number of frequency bands in the
filter bank. in the spectrum analyzer, m is equal to the number of
data points needed to achieve the specified rbw value or 1024, whichever is larger. for
more information on the analysis filter bank and its implementation, see the and the sections in the
dsp.channelizer
object.
after the spectrum analyzer splits the broadband input signal into multiple narrow bands, it computes the power in each narrow frequency band using the following equation. each zi value is the power estimate over that narrow frequency band.
l is length of the narrowband signal yi(m) and i = 1, 2, …, m−1.
the power values in all the narrow frequency bands (denoted by zi) form the z vector.
the spectrum analyzer averages the current z vector with the previous z vectors using one of the two moving average methods: video bandwidth or exponential weighting. the output of the averaging operation forms the spectral estimate vector. for details on the two averaging methods, see averaging method.
the spectrum analyzer uses the value you specify in the rbw (hz) parameter to determine the input frame length. to view the rbw (hz) parameter in the scope, click the analyzer tab on the spectrum analyzer toolstrip and navigate to the bandwidth section.
spectrum analyzer requires a minimum number of samples to compute a spectral estimate. this value is directly related to the resolution bandwidth property rbw (hz).
when you set rbw (hz) to:
auto
–– the spectrum analyzer requires 1024 samples to update the display. the spectrum analyzer determines the appropriate resolution bandwidth to ensure that there are 1024 rbw intervals over the specified frequency span. when you set rbw (hz) toauto
, the spectrum analyzer calculates rbw using this equation.scalar value –– the spectrum analyzer calculates the number of samples nsamples using this equation.
fs is the sample rate of the input signal as specified in the sample rate (hz) property. to view the sample rate (hz) in the scope, click the analyzer tab on the spectrum analyzer toolstrip and navigate to the bandwidth section.
when you specify a resolution bandwidth using the rbw (hz) parameter, you must specify a value such that there are at least two rbw intervals over the specified frequency span. the ratio of the overall span to rbw must be greater than two.
span is the frequency span over which the spectrum analyzer
computes and plots the spectrum. to view the span (hz) in the
scope, click the estimation tab on the spectrum analyzer toolstrip
and navigate to the frequency options section. to enable this
property, set frequency span to span and center
frequency
.
when the number of input samples is not sufficient to achieve the specified resolution bandwidth, the spectrum analyzer displays a message similar to this one.
the spectrum analyzer removes this message and displays a spectral estimate once you provide enough input samples.
spectrum estimation — welch's method
when you select the welch
method, the power spectrum estimate is
the averaged modified periodograms.
the algorithm in the spectrum analyzer consists of these steps:
the block buffers the input into n-point data segments. each data segment is split into p overlapping data segments, each of length m, overlapping by d points. the data segments can be represented as:
if d = m/2, the overlap is 50%.
if d = 0, the overlap is 0%.
apply a window to each of the p overlapping data segments in the time domain.
the spectrum analyzer uses rbw (hz) in the analyzer tab to determine the data window length nwindow internally. then, it partitions the input signal into a number of windowed data segments.
most window functions afford more influence to the data at the center of the set than to the data at the edges, which represents a loss of information. to mitigate that loss, the individual data sets are commonly overlapped in time. for each windowed segment, compute the periodogram by computing the discrete fourier transform. then compute the squared magnitude of the result and divide the result by m.
where u is the normalization factor for the power in the window function and is given by
you can specify the window using the window parameter in the estimation tab of the spectrum analyzer toolstrip.
the spectrum analyzer calculates and plots the power spectrum, power spectrum density, and rms using the modified periodogram estimator. for more information about the periodogram method, see .
to determine the power spectrum estimate for welch's method, the spectrum analyzer averages the result of the periodograms for the last p data segments. the averaging reduces the variance, compared to the original n-point data segment. for more details on the averaging, see averaging method.
the spectrum analyzer computes the power spectral density using:
the power spectrum is the product of the power spectral density and the resolution bandwidth, as given by this equation.
the spectrum analyzer plots the power as a spectrogram in the spectrogram mode. each line of the spectrogram is one periodogram. the time resolution of each line is 1/rbw, which is the minimum attainable resolution. achieving the resolution you want might require combining several periodograms. you then use interpolation to calculate noninteger values of 1/rbw. in the spectrogram display, time scrolls from top to bottom, so the most recent data appears at the top of the display. the offset shows the time value at which the center of the most current spectrogram line occurred.
the spectrum analyzer requires a minimum number of samples to compute a spectral estimate. this value is directly related to the resolution bandwidth (rbw).
where op is the overlap percentage, nenbw is the normalized effective noise bandwidth, fs is the input sample rate, and rbw is the resolution bandwidth.
the spectrum analyzer shows the number of samples per update in the spectrum analyzer status bar.
you can enable samples/update
in the status bar only when you set
input domain to time
and
method to welch
in the
estimation tab on the spectrum analyzer toolstrip.
overlap percentage (op)
the overlap percentage op is the value you specify in the overlap % property. to view the overlap % in the scope, click the estimation tab on the spectrum analyzer toolstrip and navigate to the window options section.
when you increase the overlap percentage, the spectrum analyzer needs fewer new input samples to compute a new spectral update.
op | nsamples |
---|---|
0% | 100 |
50% | 50 |
80% | 20 |
normalized effective noise bandwidth (nenbw)
the normalized effective noise bandwidth nenbw is a window parameter that measures the noise performance of the window. nenbw is determined using the window length and the window coefficients, and is given by the following equation:
w(n) denotes the vector of window coefficients (calculated internally). nwindow is the window length the spectrum analyzer needs to compute one spectral update, and is directly related to the resolution bandwidth and normalized effective noise bandwidth.
the rectangular window has the smallest nenbw, with a value of 1. all other windows have a larger nenbw value. for example, the hann window has an nenbw value of approximately 1.5.
the spectrum analyzer shows the value of nenbw in the spectrum analyzer status bar.
you can enable nenbw
only when you set input
domain to time
and method
to welch
in the estimation tab on the
spectrum analyzer toolstrip.
input sample rate (fs)
fs is the sample rate of the input signal.
to view the sample rate (hz) in the scope, click the
analyzer tab on the spectrum analyzer toolstrip and navigate to
the bandwidth section. you can enable this property in the status
bar at the bottom of the spectrum analyzer window. right-click the status bar and select
sample rate
.
resolution bandwidth (rbw)
resolution bandwidth controls the spectral resolution of the displayed signal. the rbw value determines the spacing between frequencies that the scope can resolve. a smaller value gives a higher spectral resolution and lowers the noise floor, that is, the spectrum analyzer can resolve frequencies that are closer to each other. however, this comes at the cost of a longer sweep time.
you can set the resolution bandwidth through the rbw (hz) property. to view rbw (hz) in the scope, click the analyzer tab on the spectrum analyzer toolstrip and navigate to the bandwidth section.
when you set rbw (hz) to:
auto
–– the spectrum analyzer requires 1024 samples to update the display. the spectrum analyzer determines the appropriate resolution bandwidth to ensure that there are 1024 rbw intervals over the specified frequency span. when you set rbw (hz) toauto
, the spectrum analyzer calculates using this equation.scalar value –– specify a value such that there are at least two rbw intervals over the specified frequency span. the ratio of the overall span to rbw must be greater than two:
span is the frequency span over which the spectrum analyzer
computes and plots the spectrum. spectrum analyzer shows the span through the
span (hz) property. to view the span (hz)
in the scope, click the estimation tab on the spectrum analyzer
toolstrip, navigate to the frequency options section, and set
frequency span to span and center
frequency
.
when the number of input samples is not sufficient to achieve the specified resolution bandwidth, the spectrum analyzer displays a message similar to this one.
the spectrum analyzer removes this message and displays a spectral estimate once you provide enough input samples.
you can enable this property in the status bar at the bottom of the spectrum analyzer
window. right-click the status bar and select rbw
.
nyquist frequency interval
when you plot the two-sided spectrum by selecting two-sided spectrum in the spectrum or spectrogram tab, the nyquist frequency interval is hz.
when you clear the two-sided spectrum, the nyquist frequency interval is hz.
frequency vector
when you set frequency (hz) to auto
, the software calculates the frequency vector for the frequency-domain input.
when you plot the two-sided spectrum by selecting two-sided spectrum in the spectrum or spectrogram tab, the frequency vector is:
when you clear the two-sided spectrum, the frequency vector is:
occupied bw
the spectrum analyzer calculates occupied bw using these steps.
calculate the total power in the measured frequency range.
determine the lower frequency value. starting at the lowest frequency in the range and moving upward, sum the power distributed in each frequency until the result is
of the total power.
determine the upper frequency value. starting at the highest frequency in the range and moving downward, sum the power distributed in each frequency until the result reaches
of the total power.
the bandwidth between the lower and upper power frequency values is the occupied bandwidth.
the frequency halfway between the lower and upper frequency values is the center frequency.
distortion measurements
the spectrum analyzer calculates distortion measurements using these steps.
estimate spectral content by finding peaks in the spectrum. when the algorithm detects a peak, it records the width of the peak and clears all monotonically decreasing values by treating all these values as if they belong to the peak. using this method, the algorithm removes all spectral content centered at dc (0 hz) from the spectrum and records the amount of bandwidth cleared (w0).
determine the fundamental power (p1) from the remaining maximum value of the displayed spectrum. create a local estimate (fe1) of the fundamental frequency by computing the central moment of the power near the peak. record the bandwidth of the fundamental power content (w1). then remove the power from the fundamental as in step 1.
determine the power and width of the higher-order harmonics (p2, w2, p3, w3, etc.) in succession by examining the frequencies closest to the appropriate multiple of the local estimate (fe1). remove any spectral content that decreases monotonically about the harmonic frequency from the spectrum before proceeding to the next harmonic.
after removing the dc, fundamental, and harmonic content from the spectrum, examine the power of the remaining spectrum for its sum (premaining), peak value (pmaxspur), and median value (pestnoise).
compute the sum of all the removed bandwidth as wsum = w0 w1 w2 ... wn.
compute the sum of powers of the second and higher-order harmonics as pharmonic = p2 p3 p4 ... pn.
estimate the sum of the noise power as:
where df is the absolute difference between frequency bins, and rbw is the resolution bandwidth of the window.
then compute the metrics for snr, thd, sinad, and sfdr from the estimates.
harmonic measurements
the harmonic distortion measurements use the spectrum trace shown in the display as the input to the measurements. the default
hann
window setting of the spectrum analyzer might exhibit leakage that can completely mask the noise floor of the measured signal.the harmonic measurements attempt to correct for leakage by ignoring all frequency content that decreases monotonically away from the maximum of harmonic peaks. if the window leakage covers more than 70% of the frequency bandwidth in your spectrum, you may see a blank reading (–) reported for snr and sinad. if your application can tolerate the increased equivalent noise bandwidth (enbw), consider using a kaiser window with a high attenuation (up to 330 db) to minimize spectral leakage.
ignore the dc component.
after windowing, the width of each harmonic component masks the noise power in the neighborhood of the fundamental frequency and harmonics. to estimate the noise power in each region, the spectrum analyzer computes the median noise level in the nonharmonic areas of the spectrum. it then extrapolates that value into each region.
nth order intermodulation products occur at a*f1 b*f2,
where f1 and f2 are the sinusoid input frequencies and |a| |b| = n. a and b are integer values.
for intermodulation measurements, compute the third-order intercept (toi) point as follows.
toilower = pf1 (pf2 - p(2f1-f2))/2
toiupper = pf2 (pf1 - p(2f2-f1))/2
toi = (toilower toiupper)/2
where p is power in decibels of the measured power referenced to 1 milliwatt (dbm).
averaging method
the spectrum analyzer can calculate the moving average using two methods:
video bandwidth — the spectrum analyzer uses a time-domain lowpass filter to smooth the noise in the signal. the video bandwidth (vbw) filter smoothes the trace and decreases noise, and the spectrum analyzer applies the filter to the data before displaying it.
video bandwidth is the bandwidth of the lowpass filter that spectrum analyzer uses to average or smooth the noise in the signal before displaying it in the scope. the spectrum analyzer computes the video bandwidth using this equation:
where,
video bandwidth does not affect the level of the noise (noise floor), but only increases the signal-to-noise ratio and smoothes the trace of the noise. when you decrease the value of vbw, the signal-to-noise ratio improves.
the cutoff frequency of the video bandwidth filter is given by:
where fs is the input sample rate and nfft is the number of fft points.
the spectrum analyzer shows the values of sample rate, vbw, and nfft in the status bar at the bottom of the display. to enable, right-click the status bar and select
sample rate
,vbw
, andnfft
.exponential — the moving average algorithm uses the exponential weighting method to update the weights and compute the moving average recursively for each z vector that comes in by using the following recursive equations:
λ — forgetting factor
— weighting factor applied to the current z vector
— current z vector
— moving average until the previous z vector
— effect of the previous z vectors on the average
— moving average including the current z vector
extended capabilities
c/c code generation
generate c and c code using matlab® coder™.
usage notes and limitations:
supports mex code generation by treating the calls to the object as extrinsic. does not support code generation for standalone applications.
see (matlab coder).
version history
introduced in r2012br2022a: dsp.spectrumanalyzer
system object will be removed
the dsp.spectrumanalyzer
system object will be removed in a future release. use the spectrumanalyzer
object instead.
update code
the spectrumanalyzer
object has the same properties as the
dsp.spectrumanalyzer
object. however, the default value of the
method
property has changed to 'filter-bank'
, and
the default value of the averagingmethod
property has changed to
'vbw'
, which is video bandwidth.
no updates to your code are required except for:
replacing instances of
dsp.spectrumanalyzer
withspectrumanalyzer
.updating the values of
method
andaveragingmethod
properties, if required.
this table shows how the system object is typically used and explains how to update existing code to use the
spectrumanalyzer
object.
discouraged usage | recommended replacement |
---|---|
using the default version of
sa = dsp.spectrumanalyzer dsp.spectrumanalyzer with properties: numinputports: 1 inputdomain: 'time' spectrumtype: 'power' viewtype: 'spectrum' samplerate: 10000 method: 'welch' plotastwosidedspectrum: 1 frequencyscale: 'linear' advanced frequencyspan: 'full' frequencyresolutionmethod: 'rbw' rbwsource: 'auto' overlappercent: 0 window: 'hann' spectrumunits: 'dbm' averagingmethod: 'running' spectralaverages: 1 referenceload: 1 frequencyoffset: 0 | replacing with the
the
to retain the same default
behavior as the sa = spectrumanalyzer(method="welch",averagingmethod="exponential") spectrumanalyzer with properties: inputdomain: 'time' spectrumtype: 'power' viewtype: 'spectrum' samplerate: 10000 method: 'welch' plotastwosidedspectrum: 1 frequencyscale: 'linear' plottype: 'line' axesscaling: 'auto' advanced rbwsource: 'auto' frequencyspan: 'full' overlappercent: 0 window: 'hann' averagingmethod: 'exponential' forgettingfactor: 0.9000 spectrumunits: 'dbm' referenceload: 1 frequencyoffset: 0 |
display spectrum display
spectrum data on the spectrum analyzer using the
swv = dsp.sinewave(frequency=100,samplerate=1000); swv.samplesperframe = 1000; san = dsp.spectrumanalyzer(samplerate=swv.samplerate); data = []; for ii = 1:250 x = swv() 0.05*randn(1000,1); san(x); if san.isnewdataready data = [data;getspectrumdata(san)]; end end release(san); | display spectrum display
spectrum data on the spectrum analyzer using the swv = dsp.sinewave(frequency=100,samplerate=1000); swv.samplesperframe = 1000; san = spectrumanalyzer(samplerate=swv.samplerate,... method="welch",averagingmethod="exponential"); data = []; for ii = 1:250 x = swv() 0.05*randn(1000,1); san(x); if san.isnewdataready data = [data;getspectrumdata(san)]; end end release(san); |
r2022a: ccdf measurements will be removed from the dsp.spectrumanalyzer
object
the ccdfmeasurements
property will be removed from the dsp.spectrumanalyzer
object. if you try to edit these measurements from the
command line or from the user interface (ui), the object throws a warning message.
use the powermeter
object
instead to plot and visualize the ccdf measurements.
matlab 命令
您点击的链接对应于以下 matlab 命令:
请在 matlab 命令行窗口中直接输入以执行命令。web 浏览器不支持 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
- (español)
- (english)
- (english)
europe
- (english)
- (english)
- (deutsch)
- (español)
- (english)
- (français)
- (english)
- (italiano)
- (english)
- (english)
- (english)
- (deutsch)
- (english)
- (english)
- switzerland
- (english)
asia pacific
- (english)
- (english)
- (english)
- 中国
- (日本語)
- (한국어)