spectrumAnalyzer
Description
The spectrumAnalyzer
object displays frequency-domain signals and
the frequency spectrum of time-domain signals. The scope shows the spectrum view and the
spectrogram view. The object performs spectral estimation using the filter bank method and
Welch's method of averaged modified periodograms. You can customize the spectrum analyzer
display to show the data and the measurement information that you need. For more details, see
Algorithms. The spectrum analyzer can
display the power spectrum of the signal in three units, Watts
,
dBm
, and dBW
. For more information on
how to convert the power within these three units, see Convert the Power Between Units.
To display the spectra of signals in the spectrum analyzer:
Create the
spectrumAnalyzer
object and set its properties.Call the object with arguments as if it were a function.
Creation
Description
scope = spectrumAnalyzer
creates a
spectrumAnalyzer
object that displays the frequency spectrum of real or
complex signals.
scope = spectrumAnalyzer(Name=Value)
specifies nondefault
properties for scope
using one or more name-value arguments. For example,
to display both spectrum and spectrogram, set ViewType
to
"spectrum-and-spectrogram"
.
Properties
Frequently Used
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 want to
visualize time-domain signals, the spectrum analyzer transforms the signal to the
frequency spectrum based on the algorithm you specify 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
— Type of spectrum to display
"power"
(default) | "power-density"
| "rms"
The type of spectrum to display, specified as one of the following:
"power"
— Power spectrum."power-density"
— Power spectral density. The power spectral density is the squared magnitude of the spectrum normalized to a bandwidth of 1 hertz."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 Scope tab on the spectrum analyzer toolstrip, click
the drop down arrow of 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
— View to display
"spectrum"
(default) | "spectrogram"
| "spectrum-and-spectrogram"
View to display, specified as one of the following:
"spectrum"
— Display the frequency spectrum of signals."spectrogram"
— Display the spectrogram of signals. Spectrogram shows the frequency content over time. Each line of the spectrogram is one periodogram. Time scrolls from the top to the bottom of the display. The most recent spectrogram update is at the top of the display."spectrum-and-spectrogram"
— Display both spectrum and spectrogram.
To learn more about how the spectrum analyzer computes spectrum and spectrogram, see the Algorithms section.
Tunable: Yes
Scope Window Use
In the Scope tab on the spectrum analyzer toolstrip, select Spectrum, Spectrogram, or both.
Data Types: char
| string
SampleRate
— Sample rate of input
10000
(default) | positive scalar
The sample rate of the input in Hz, specified as a positive scalar.
Tunable: Yes
Scope Window Use
Click the Scope tab on the spectrum analyzer toolstrip. In the Bandwidth section, specify Sample Rate (Hz) to a finite scalar.
The spectrum analyzer shows the sample rate in the status bar at the bottom of the display.
Data Types: double
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 Algorithms.
Tunable: Yes
Dependency
To enable this property, set InputDomain
to "time"
.
Scope Window Use
In the Estimation tab of the spectrum analyzer toolstrip,
set Estimation 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, seepwelch
.
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
— Scale to display frequency
"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."log"
— Use a logarithmic scale to display frequencies on the x-axis.
Tunable: Yes
Dependency
To set this property to "log"
, set the
PlotAsTwoSidedSpectrum
property to
false
.
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
PlotType
— Plot type for normal traces
"line"
(default) | "stem"
Type of plot to use for displaying 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 Scope tab on the spectrum analyzer toolstrip,
navigate to the Configuration section and click
Settings. In the Spectrum Analyzer Settings window that
opens, set Plot Type to Line
or
Stem
.
To enable the Plot Type, you must:
Select Spectrum in the Views section of the Scope tab.
Enable the Normal Trace check box in the Trace Options section of the Spectrum tab.
Data Types: char
| string
AxesScaling
— Axes scaling mode
"auto"
(default) | "manual"
| "onceatstop"
| "updates"
Axes scaling mode, specified as one of the following:
"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 and you call therelease
function."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
AxesScalingNumUpdates
— Number of updates before scaling
100 (default) | positive integer
Number of updates before scaling, specified as a positive integer.
Tunable: Yes
Dependency
To enable this property, set AxesScaling
to "updates"
.
Data Types: double
Advanced
FrequencyResolutionMethod
— Frequency resolution method
"rbw"
(default) | "num-frequency-bands"
| "window-length"
Frequency resolution method of the spectrum analyzer, specified as one of these options:
"rbw"
–– TheRBWSource
andRBW
properties control the frequency resolution (in Hz) of the analyzer."num-frequency-bands"
–– Applies only when you setMethod
to"filter-bank"
. TheFFTLengthSource
andFFTLength
properties control the frequency resolution."window-length"
–– Applies only when you setMethod
to"welch"
. TheWindowLength
property controls the frequency resolution.
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 Resolution section, set Resolution Method to one of the available options.
Data Types: char
| string
RBWSource
— Source of resolution bandwidth value
"auto"
(default) | "property"
The source of the resolution bandwidth (RBW), specified as
"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 FrequencyResolutionMethod
to
"rbw"
.
Scope Window Use
Click the Estimation tab on the spectrum analyzer
toolstrip. In the Frequency Resolution section, set
RBW (Hz) to either Auto
or a
positive scalar.
Data Types: char
| string
RBW
— Resolution bandwidth
9.76
(default) | positive scalar
Resolution bandwidth (RBW) in Hz, specified as a positive scalar. Specify the value to ensure that there are at least two RBW intervals over the specified frequency span. The ratio of the overall span to RBW satisfies this condition:
Specify the overall span based on how you set the FrequencySpan
property.
RBW controls the spectral resolution of the displayed signal. The RBW value determines the spacing between frequencies that can be resolved. 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.
Tunable: Yes
Dependency
To enable this property, set RBWSource
to "property"
.
Scope Window Use
Click the Estimation tab on the spectrum analyzer toolstrip. In the Frequency Resolution section, set RBW (Hz) to a positive scalar.
The spectrum analyzer shows the value of RBW in the status bar at the bottom of the display.
Data Types: double
WindowLength
— Window length
1024
(default) | integer greater than 2
Since R2024a
Window length in samples that the object uses to compute the spectral estimates, specified as an integer greater than 2. This property controls the frequency resolution.
Tunable: Yes
Dependencies
To enable this property, set:
Method
to"welch"
.FrequencyResolutionMethod
to"window-length"
.
Scope Window Use
Click the Estimation tab on the spectrum analyzer toolstrip. In the Frequency Resolution section, set the Window Length to a positive integer greater than 2.
To enable Window Length, set:
Estimation Method to
Welch
.Resolution Method to
Window length
.
WindowInvariantSamplesPerUpdate
— Maintain samples per update
false
(default) | true
Since R2024b
Set this parameter to true
to maintain the number of samples
per update Nsamples at 1024 regardless of
the window you choose in the Window
property. The RBW value
adjusts according to the window you choose.
When you set this parameter to false
, the object maintains the
same RBW value and adjusts the required number of samples per update
Nsamples depending on the window you
choose.
Tunable: Yes
Dependencies
To enable this property, set:
Method
to"welch"
.FrequencyResolutionMethod
to"rbw"
.RBWSource
to"auto"
.
Data Types: logical
FFTLengthSource
— Source of FFT length
"auto"
(default) | "property"
Source of the FFT length, specified as one of these:
"auto"
–– The value of FFT length depends on the setting of the frequency resolution method. When you set:FrequencyResolutionMethod
to"rbw"
, the FFT length equals the number of samples per update, Nsamples. For more details on Nsamples, see the Algorithms section.FrequencyResolutionMethod
to"window-length"
, the FFT length equals the value you specify in theWindowLength
property or 1024, whichever is larger.FrequencyResolutionMethod
to"num-frequency-bands"
, the FFT length equals the input frame size (number of rows).
"property"
–– The number of FFT points equals the value you specify in theFFTLength
property.
Tunable: Yes
Dependency
To enable this property, set:
Method
to"welch"
.Method
to"filter-bank"
andFrequencyResolutionMethod
to"num-frequency-bands"
.
Scope Window Use
Click the Estimation tab on the spectrum analyzer toolstrip.
In the Frequency Resolution section, set the FFT
Length to Auto
or a positive
integer.
Data Types: char
| string
FFTLength
— Length of FFT
1024
(default) | positive integer
Since R2024a
Length of the FFT that the spectrum analyzer uses to compute spectral estimates, specified as a positive integer.
Tunable: Yes
Dependencies
To enable this property, set FFTLengthSource
to
"property"
.
Scope Window Use
Click the Estimation tab on the spectrum analyzer
toolstrip. In the Frequency Resolution section, set the
FFT Length to Auto
or a positive
integer.
FilterSharpness
— Sharpness of lowpass filter
0.3
(default) | nonnegative scalar in the range [0,1]
Sharpness of the prototype lowpass filter, specified as a real nonnegative scalar in the range [0,1].
Increasing the filter sharpness decreases the spectral leakage and gives a more accurate power reading.
Tunable: Yes
Dependencies
To enable this property, set Method
to "filter-bank"
.
Scope Window Use
Click the Estimation tab on the spectrum analyzer toolstrip. In the Frequency Resolution section, set Filter Sharpness.
To enable this parameter, set Input Domain to
Time
in the Estimation tab.
Data Types: double
FrequencyVectorSource
— Source of frequency vector
"auto"
(default) | "property"
Source of the frequency vector, specified as one of the following:
"auto"
— The spectrum analyzer computes the frequency vector based on the frame size of the input signal and the specified sample rate."property"
— Enter a custom vector in theFrequencyVector
property.
Tunable: Yes
Dependency
To enable this property, set InputDomain
to "frequency"
.
Scope Window Use
Click the Estimation tab on the spectrum analyzer
toolstrip. In the Domain section, set Frequency
(Hz) to either Auto
or 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: 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"
.
Scope Window Use
Click the Estimation tab on the spectrum analyzer
toolstrip. In the Domain section, set Frequency
(Hz) to either Auto
or 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: double
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
Frequency span over which the spectrum analyzer computes and plots the spectrum,
specified as a positive scalar in Hz. 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:
InputDomain
to"time"
FrequencySpan
to"span-and-center-frequency"
Scope Window Use
Click the Estimation tab on the spectrum analyzer
toolstrip. In the Frequency Options section, set
Frequency Span to Span and Center
Frequency
and Span (Hz) to a positive
scalar.
To enable the Frequency Span, set Input
Domain to Time
.
Data Types: double
CenterFrequency
— Center of frequency span
0
(default) | real scalar
Center of frequency span over which the spectrum analyzer computes and plots the
spectrum, specified as a real scalar in Hz. The overall frequency span, defined by
Span
and this property, must fall within the Nyquist Frequency Interval.
Tunable: Yes
Dependency
To enable this property, set:
InputDomain
to"time"
FrequencySpan
to"span-and-center-frequency"
Scope Window Use
Click the Estimation tab on the spectrum analyzer
toolstrip. In the Frequency Options section, set
Frequency Span to Span and Center
Frequency
and Center Frequency (Hz) to a real
scalar.
To enable the Frequency Span, set Input
Domain to Time
.
Data Types: double
StartFrequency
— Starting frequency in frequency interval
-5e3
(default) | real scalar
Starting frequency in the frequency interval over which the spectrum analyzer
computes and plots the spectrum, specified as a real scalar in Hz. 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:
InputDomain
to"time"
FrequencySpan
to"start-and-stop-frequencies"
Scope Window Use
Click the Estimation tab on the spectrum analyzer
toolstrip. In the Frequency Options section, set
Frequency Span to Start and Stop
Frequencies
and Start Frequency (Hz) to a real
scalar.
To enable the Frequency Span, set Input
Domain to Time
.
Data Types: double
StopFrequency
— Ending frequency in frequency interval
5e3
(default) | real scalar
Ending frequency in the frequency interval over which the spectrum analyzer
computes and plots the spectrum, specified as a real scalar in Hz. 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:
InputDomain
to"time"
FrequencySpan
to"start-and-stop-frequencies"
Scope Window Use
Click the Estimation tab on the spectrum analyzer
toolstrip. In the Frequency Options section, set
Frequency Span to Start and Stop
Frequencies
and Stop Frequency (Hz) to a real
scalar.
To enable the Frequency Span, set Input
Domain to Time
.
Data Types: double
OverlapPercent
— Percentage of overlap
0
(default) | scalar in the range [0 100)
Percentage of overlap between the previous and current buffered data segments, specified as a scalar in the range [0 100). The overlap creates a window segment that the object uses to compute a spectral estimate.
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 Overlap (%).
To enable the Overlap (%), set Input
Domain to Time
and Estimation
Method to Welch
in the
Estimation tab on the spectrum analyzer toolstrip.
Data Types: double
Window
— Window function
"hann"
(default) | "blackman-harris"
| "chebyshev"
| "custom"
| "flat-top"
| "hamming"
| "kaiser"
| "rectangular"
Window function, specified as one of the following preset windows. For more information on a window option, click the link to the corresponding function.
Window Option | Corresponding Signal Processing Toolbox™ Function |
---|---|
"hann" | hann |
"blackman-harris" | blackmanharris |
"chebyshev" | chebwin |
"flat-top" | flattopwin |
"hamming" | hamming |
"kaiser" | kaiser |
"rectangular" | rectwin |
To use 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 Estimation 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 array | string scalar
Name of custom window function, specified as a character array or string scalar. The custom window function name must be on the MATLAB® path. Use this property to customize a window function using additional properties available with the Signal Processing Toolbox.
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 a custom window function name.
Data Types: char
| string
SidelobeAttenuation
— Sidelobe attenuation of window
60
(default) | scalar greater than or equal to 45
Sidelobe attenuation of the window in decibels (dB), specified as a positive
scalar greater than or equal to 45
.
Tunable: Yes
Dependency
To enable this property, set Window
to "chebyshev"
or
"kaiser"
.
Scope Window Use
Click the Estimation tab on the spectrum analyzer toolstrip. In the Window Options section, set the Attenuation (dB).
To enable the Attenuation (dB), set:
Input Domain to
Time
Estimation Method to
Welch
Window to either
Chebyshev
orKaiser
in the Estimation tab on the spectrum analyzer toolstrip.
Data Types: double
AveragingMethod
— Averaging 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 on averaging methods, see Averaging Method.
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
ForgettingFactor
— Forgetting factor of weighted average method
0.9
(default) | scalar in the range [0,1]
Forgetting factor of the exponential weighted averaging method, specified as a scalar in the range [0,1].
Tunable: Yes
Dependency
To enable this property, set:
InputDomain
to"time"
.AveragingMethod
to"exponential"
Scope Window Use
Click the Estimation tab on the spectrum analyzer toolstrip. In the Averaging section, set Forgetting Factor.
To enable the Forgetting Factor, set Input
Domain to Time
and Averaging
Method to Exponential
.
Data Types: double
VBWSource
— Source of video bandwidth
"auto"
(default) | "property"
Source of the video bandwidth (VBW), specified as either "auto"
or "property"
.
"auto"
— The spectrum analyzer adjusts the VBW such that the equivalent forgetting factor is 0.9."property"
— The spectrum analyzer adjusts the VBW using the value specified in theVBW
property.
For more details on the video bandwidth method, see Averaging Method.
Tunable: Yes
Dependency
To enable this property, set InputDomain
to "time"
and AveragingMethod
to vbw
.
Scope Window Use
Click the Estimation tab on the spectrum analyzer
toolstrip. In the Averaging section, set VBW
(Hz) to either Auto
or a positive real
scalar less than or equal to Sample Rate (Hz)/2.
To enable the VBW (Hz), set Input
Domain to Time
and Averaging
Method to VBW
.
Data Types: char
| string
VBW
— Video bandwidth
10
(default) | positive scalar
Video bandwidth, specified as a positive scalar less than or equal to SampleRate
/2. For more details on the video bandwidth method, see Averaging Method.
The spectrum analyzer shows the value of VBW in the status bar at the bottom of the display.
Tunable: Yes
Dependency
To enable this property, set VBWSource
to "property"
.
Scope Window Use
Click the Estimation tab on the spectrum analyzer
toolstrip. In the Averaging section, set VBW
(Hz) to either Auto
or enter a positive real
scalar that is less than or equal to Sample Rate (Hz)/2.
To enable the VBW (Hz), set Input
Domain to Time
and Averaging
Method to VBW
.
Data Types: double
InputUnits
— Units of frequency-domain input
"dBm"
(default) | "dBuV"
(since R2023b) | "dBV"
| "dBW"
| "Vrms"
| "Watts"
| "none"
Units of the frequency-domain input, specified as "dBm"
,
"dBuV"
(since R2023b),
"dBV"
, "dBW"
, "Vrms"
,
"Watts"
, or "none"
. The spectrum analyzer
scales frequency data according to the display unit.
Tunable: Yes
Dependency
To enable this property, set InputDomain
to "frequency"
.
Scope Window Use
Click the Estimation tab on the spectrum analyzer toolstrip. In the Domain section, set Input Unit.
To enable the Input Unit, set Input
Domain to Frequency
.
Data Types: char
| string
SpectrumUnits
— Units of the spectrum
"dBm"
(default) | "dBFS"
| "dBuV"
(since R2023b) | "dBV"
| "dBW"
| "Vrms"
| "Watts"
| "dBm/Hz"
| "dBW/Hz"
| "dBFS/Hz"
| "Watts/Hz"
| "auto"
Units of the spectrum, specified as one of the following:
"dBm"
"dBFS"
"dBuV"
(since R2023b)"dBV"
"dBW"
"Vrms"
"Watts"
"dBm/Hz"
"dBW/Hz"
"dBFS/Hz"
"Watts/Hz"
"auto"
Tunable: Yes
Dependency
The available spectrum units 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" | "dBuV" (since R2023b),
"dBV" , "Vrms" | |
"frequency" | ― | "auto" , "dBm" , "dBuV" (since R2023b),
"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"
, 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 value
"auto"
(default) | "property"
Source of the dBFS scaling factor, specified 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"
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 Scope 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
— dBFS full scale
1
(default) | positive scalar
dBFS full scale, specified a positive scalar.
Tunable: Yes
Dependency
To enable this property, set:
InputDomain
to"time"
SpectrumType
to"power"
or"power-density"
SpectrumUnits
to"dBFS"
or"dBFS/Hz"
FullScaleSource
to"property"
Scope Window Use
Click the Spectrum tab on the spectrum analyzer toolstrip.
In the Scale section, set the Full Scale
to either Auto
or enter a positive scalar.
To enable the Full Scale:
In the Scope 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: double
ReferenceLoad
— Reference load to compute power levels
1
(default) | positive scalar
Load that the scope uses as a reference to compute power levels, specified as a positive scalar in Ohms.
Tunable: Yes
Dependency
To enable this property, set:
SpectrumType
to"power"
or"power-density"
.SpectrumUnits
to any option other than"dBFS"
or"dBFS/Hz"
.
Scope Window Use
Click the Spectrum tab on the spectrum analyzer toolstrip. In the Scale section, set Reference Load (Ω).
Data Types: double
FrequencyOffset
— Offset to apply to frequency axis
0
(default) | scalar | vector
Offset to apply to the frequency axis (x-axis) in units of Hz, specified as one of the following:
Scalar — Apply the same frequency offset to all channels.
Vector — Apply a specific frequency offset for each channel. The vector length must be equal to the number of input channels.
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
Click the Scope tab on the spectrum analyzer toolstrip. In the Bandwidth section, set Offset (Hz).
Data Types: double
Spectrogram
SpectrogramChannel
— Channel for which spectrogram is plotted
1
(default) | positive integer
Channel for which the spectrogram is plotted, specified as a positive 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
Click the Spectrogram tab on the spectrum analyzer toolstrip. In the Channel section, select a Channel.
Data Types: double
TimeResolutionSource
— Source of the time resolution
"auto"
(default) | "property"
Source of the time resolution of each spectrogram line, specified as either
"auto"
or "property"
.
When you set RBWSource
and TimeResolutionSource
to
"auto"
, then RBW is set such that there are 1024 RBW intervals in
one frequency span. The time resolution is set to 1/RBW
.
When RBWSource
is set to "auto"
and
TimeResolutionSource
is set to "property"
,
then time resolution becomes the main control and RBW is set to 1/TimeResolution
Hz.
When RBWSource
is set to "property"
and
TimeResolutionSource
is set to "auto"
, then
RBW becomes the main control and the time resolution is set 1/RBW s.
When both RBWSource
and
TimeResolutionSource
are set to "property"
,
then the specified time resolution value must be equal to or larger than the minimum
attainable time resolution which is defined by 1/RBW. Several spectral estimates are
combined into one spectrogram line to obtain the desired time resolution.
Tunable: Yes
Dependency
To enable this property, set:
InputDomain
to"time"
.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 Scope tab and set
Input Domain to Time
in the
Estimation tab.
Data Types: char
| string
TimeResolution
— Time resolution of each spectrogram line
0.001
(default) | positive scalar
Time resolution of each spectrogram line in seconds, specified as a positive scalar.
Tunable: Yes
Dependency
To enable this property, set:
InputDomain
to"time"
.ViewType
to"spectrogram"
or"spectrum-and-spectrogram"
.TimeResolutionSource
to"property"
.
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 Scope tab and set
Input Domain to Time
in the
Estimation tab.
Data Types: double
TimeSpanSource
— Source of time span value
"auto"
(default) | "property"
Source for the time span of the spectrogram, specified as either one of these:
"auto"
–– The spectrogram displays 100 spectrogram lines at any given time."property"
–– The spectrogram uses the time duration you specify in seconds in theTimeSpan
property.The time span that you specify must be at least two times larger than 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"
.
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 of spectrogram
0.1
(default) | positive scalar
Time span of the spectrogram display in seconds, specified as a positive scalar. 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
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: double
Measurements
MeasurementChannel
— Channel for which to obtain measurements
1
(default) | positive integer
The channel for which you need to obtain measurements, specified as a positive integer in the range [1 N], where N is the number of input channels.
Tunable: Yes
Scope Window Use
Click the Measurements tab on the spectrum analyzer toolstrip. In the Channel section, select a Channel.
Data Types: double
ChannelMeasurements
— Channel measurements
ChannelMeasurementsConfiguration
object
Channel measurements, specified as a ChannelMeasurementsConfiguration
object. Enable channel measurements to
compute and display the occupied bandwidth or adjacent channel power ratio. All
ChannelMeasurementsConfiguration
properties are tunable.
Tunable: Yes
Dependency
To enable this property, set ViewType
to either "spectrum"
or
"spectrum-and-spectrogram"
.
Scope Window Use
Click the Channel Measurements tab on the spectrum analyzer toolstrip and modify the measurement settings.
The Channel Measurements tab appears when you select Spectrum in the Scope tab.
CursorMeasurements
— Cursor measurements
CursorMeasurementsConfiguration
object
Cursor measurements, specified as a CursorMeasurementsConfiguration
object. Enable cursor measurements to
display waveform cursors. All CursorMeasurementsConfiguration
properties are tunable.
Tunable: Yes
Scope Window Use
Click the Measurements tab on the spectrum analyzer toolstrip and modify the cursor measurements in the Cursors section.
DistortionMeasurements
— Distortion measurements
DistortionMeasurementsConfiguration
object
Distortion measurements, specified as a DistortionMeasurementsConfiguration
object. Enable distortion measurements
to compute and display the harmonic distortion and intermodulation distortion. All
DistortionMeasurementsConfiguration
properties are tunable. For
more details, see Distortion Measurements and Harmonic Measurements.
Tunable: Yes
Dependency
To enable this property, set ViewType
to either "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 Scope tab.
PeakFinder
— Peak finder measurement
PeakFinderConfiguration
object
Peak finder measurement, specified as a PeakFinderConfiguration
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 either "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 Scope tab.
SpectralMask
— Spectral mask configuration
SpectralMaskConfiguration
object
Spectral mask configuration, specified as a SpectralMaskConfiguration
object. Use the spectral mask configuration to
draw upper and lower or upper or lower mask lines in the power and power-density
plots. All SpectralMaskConfiguration
properties are tunable.
Tunable: Yes
Dependency
To enable this property, set:
ViewType
to either"spectrum"
or"spectrum-and-spectrogram"
.SpectrumType
to either"power"
or"power-density"
.
Scope Window Use
Click the Spectral Mask tab on the spectrum analyzer toolstrip and modify the settings.
The Spectral Mask tab appears when you:
Select Spectrum in the Scope tab.
In the drop-down list under Spectrum, choose either
Power
orPower Density
.
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
— Spectrum analyzer window position in pixels
[left bottom 800 500]
(default) | [left bottom width height
]
Spectrum analyzer window position in pixels, specified 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 of this
property.
By default, the window appears at the center of your screen with a width of
800
pixels and height of 500
pixels. The exact
center coordinates depend on your screen resolution.
Tunable: Yes
MaximizeAxes
— Maximize axes control
"auto"
(default) | "on"
| "off"
Maximize axes control, specified as one of the following:
"auto"
–– The spectrum analyzer maximizes axes only if the display does not contain any labels or title annotations."on"
–– The spectrum analyzer maximizes axes in all displays."off"
–– The spectrum analyzer does not maximize axes in any display.
Tunable: Yes
Data Types: char
| string
PlotNormalTrace
— Option to plot normal trace
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 Scope tab.
Data Types: logical
PlotMaxHoldTrace
— Option to plot max-hold trace
false
(default) | true
Option to plot max-hold trace, specified as true
or
false
. To compute and plot the maximum-hold spectrum of each
input channel, set this property to true
. The spectrum analyzer
computes the maximum-hold spectrum at each frequency bin by keeping the maximum value
of all the power spectrum estimates. When you change the value of 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 Scope tab.
Data Types: logical
PlotMinHoldTrace
— Option to plot min-hold trace
false
(default) | true
Option to plot min-hold trace, specified as true
or
false
. To compute and plot the minimum-hold spectrum of each
input channel, set this property to true
. The spectrum analyzer
computes the minimum-hold spectrum at each frequency bin by keeping the minimum value
of all the power spectrum estimates. When you change the value of 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 Scope 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 Scope tab on the spectrum analyzer toolstrip. In the Configuration section, click Settings, and 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 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 Scope tab on the spectrum analyzer toolstrip. In the Configuration section, click Settings, and enter Y-Label.
To enable the Y-Label, select Spectrum in the Scope tab.
Data Types: char
| string
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"
.
Scope Window Use
Click the Scope tab on the spectrum analyzer toolstrip. In the Configuration section, click Settings, and enter Y-Limits.
To enable the Y-Limits, select Spectrum in the Scope tab.
ColorLimits
— Color limits of spectrogram
[-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"
.
Scope Window Use
Click the Scope tab on the spectrum analyzer toolstrip. In the Configuration section, click Settings, and enter Color Limits.
To enable the Color Limits, select Spectrogram in the Scope tab.
Colormap
— Color look-up table
"jet"
(default) | "bone"
| "cool"
| "copper"
| "gray"
| "hot"
| "parula"
| three-column matrix
Color look-up table, specified as a valid colormap name or a three-column matrix with values in the range [0,1] defining RGB triplets.
Tunable: Yes
Dependencies
To enable this property, set the ViewType
property to "spectrogram"
or
"spectrum-and-spectrogram"
.
Scope Window Use
Click the Scope tab on the spectrum analyzer toolstrip. In the Configuration section, click Settings, and enter Color Map.
To enable the Color Map, select Spectrogram in the Scope tab.
Data Types: double
| char
| string
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 Scope tab on the Spectrum Analyzer toolstrip. In the Configuration section, click Settings, and select Show Grid.
Data Types: logical
ShowLegend
— Show or hide legend
false
(default) | true
Show or hide 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 Scope tab on the spectrum analyzer toolstrip. To see the legend, click Legend in the Configuration section.
To enable the Legend, select Spectrum in the Scope tab.
Data Types: logical
ShowColorbar
— Show or hide color bar
true
(default) | false
Show or hide color bar, specified as true
or
false
.
Tunable: Yes
Dependencies
To enable this property, set the ViewType
property to "spectrogram"
or
"spectrum-and-spectrogram"
.
Scope Window Use
Click the Scope tab on the spectrum analyzer toolstrip. To see the color bar, click Colorbar in the Configuration section.
To enable the Colorbar, select Spectrogram in the Scope 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 Scope tab on the spectrum analyzer toolstrip. To see the legend, click Legend in the Configuration section.
Data Types: char
AxesLayout
— Layout of axes
"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 Scope tab on the spectrum analyzer toolstrip. Select Spectrum and Spectrogram. In the Configuration section, select and update Layout.
Data Types: char
| string
Color and Styling
BackgroundColor
— Background color in scope
[33 33 33
]/255
(default) | RGB triplet | hexadecimal color code | "r"
| "g"
| "b"
| ...
Since R2024b
Background color in scope, specified as an RGB triplet, a hexadecimal color code, a color name, or a short name. For more information on all the acceptable values, see Color.
Tunable: Yes
Scope Window Use
On the Scope tab, click Settings, and select a Background color.
Data Types: double
| char
AxesColor
— Color of axes in scope
[18 18 18
]/255
(default) | RGB triplet | hexadecimal color code | "r"
| "g"
| "b"
| ...
Since R2024b
Color of the axes in the scope, specified as an RGB triplet, a hexadecimal color code, a color name, or a short name. For more information on all the acceptable values, see Color.
Tunable: Yes
Scope Window Use
On the Scope tab, click Settings, and select an Axes color.
Data Types: double
| char
FontColor
— Color of labels in scope
[217 217 217
]/255
(default) | RGB triplet | hexadecimal color code | "r"
| "g"
| "b"
| ...
Since R2024b
Colors of the labels in the scope, specified as an RGB triplet, a hexadecimal color code, a color name, or a short name. Use this property to set the color of the scope title, x-axis and y-axis labels, and the axes ticks. For more information on all the acceptable values, see Color.
Tunable: Yes
Scope Window Use
On the Scope tab, click Settings, and select a Labels color.
Data Types: double
| char
FontSize
— Scope font size
8.5
(default) | positive scalar
Since R2024b
Scope font size, specified as a positive scalar. Use this property to set the font size for the ticks, labels, title, and measurements of the scope.
Tunable: Yes
Scope Window Use
On the Scope tab, click Settings, and set the Font Size to one of the available values.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
LineVisible
— Visibility of plot lines in scope
"on"
or 1
(default) | "off"
or 0
| vector of logical values
Since R2024b
Visibility of plot lines in scope, specified as one of these:
"on"
or 1 –– The scope displays the plot line. If you are plotting multiple lines, the scope applies this value to all the lines."off"
or 0 –– The scope hides the plot line. If you are plotting multiple lines, the scope applies this value to all the lines.vector of logical values –– The scope applies the values to the lines in the plot. The length of the vector must equal the number of lines that you are plotting in the scope.
Tunable: Yes
Scope Window Use
On the Scope tab, click Settings, and select the Visible property.
Data Types: logical
LineStyle
— Scope line style
"-"
(default) | "--"
| ":"
| "-."
| "none"
| cell array or array
Since R2024b
Scope line style, specified as one of these options:
"-"
–– Solid line"--"
–– Dashed line":"
–– Dotted line"-."
–– Dash-dotted line"none"
–– No line
If you provide a cell array or an array of these values, then the length of the array must equal the number of lines that you are plotting in the scope.
Tunable: Yes
Scope Window Use
On the Scope tab, click Settings, and set Style.
LineWidth
— Scope line width
1.5
(default) | positive scalar | vector of positive scalar values
Since R2024b
Scope line width, specified as a positive scalar or a vector of positive scalar values in points, where 1 point = 1/72 of an inch. If you specify a scalar value and are plotting multiple lines, then the scope applies the same value to all the lines. If you provide a vector of values, the length of the vector must equal the number of lines that you are plotting.
If the line has markers, then the line width also affects the marker edges. The line width cannot be thinner than the width of a pixel. If you set the line width to a value that is less than the width of a pixel on your system, the line displays as one pixel wide.
Tunable: Yes
Scope Window Use
On the Scope tab, click Settings, and set Width.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
LineColor
— Scope line color
colororder
("default"
) (default) | matrix of RGB triplets | array of color names
Since R2024b
Scope line color, specified as a matrix of RGB triplets or an array of color names.
Tunable: Yes
Matrix of RGB Triplets
Specify an m-by-3 matrix, where each row is an RGB triplet. An RGB triplet is a three-element vector containing the intensities of the red, green, and blue components of a color. The intensities must be in the range [0,1]. For example, this matrix defines the new colors as blue, dark green, and orange.
scope.LineColor = [1.0 0.0 0.0 0.0 0.4 0.0 1.0 0.5 0.0];
Array of Color Names or Hexadecimal Color Codes
Specify any combination of color names, short names, or hexadecimal color codes.
To specify one color, set the line color to a character vector or a string scalar. For example,
scope.LineColor = 'red'
specifies red as the only color in the color order.To specify multiple colors, set
LineColor
to a cell array of character vectors or a string array. For example,scope.LineColor = {'red','green','blue'}
specifies red, green, and blue as the colors.
A hexadecimal color code starts with a hash symbol (#
) followed by
three or six hexadecimal digits, which can range from 0
to
F
. The values are not case sensitive. Thus, the color codes
'#FF8800'
, '#ff8800'
, '#F80'
, and
'#f80'
are equivalent.
This table lists the color names and short names with the equivalent RGB triplets and hexadecimal color codes.
Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
"red" | "r" | [1 0 0] | "#FF0000" | |
"green" | "g" | [0 1 0] | "#00FF00" | |
"blue" | "b" | [0 0 1] | "#0000FF" | |
"cyan"
| "c" | [0 1 1] | "#00FFFF" | |
"magenta" | "m" | [1 0 1] | "#FF00FF" | |
"yellow" | "y" | [1 1 0] | "#FFFF00" | |
"black" | "k" | [0 0 0] | "#000000" | |
"white" | "w" | [1 1 1] | "#FFFFFF" |
Scope Window Use
On the Scope tab, click Settings, and set Color.
Data Types: single
| double
| char
| string
| cell
LineMarker
— Scope line marker
"none"
| "o"
| "+"
| "*"
| "."
| ...
Since R2024b
Scope line marker symbol, specified as one of the values listed in this table. By default, the object does not display markers. Specifying a marker symbol adds markers at each data point or vertex.
Tunable: Yes
Scope Window Use
On the Scope tab, click Settings, and set Marker.
Usage
Description
scope(
displays the frequency
spectrum of the time-domain signal in the spectrum analyzer. If
signal
)signal
is a frequency-domain signal, the signal is displayed
directly in the spectrum analyzer.
scope(signal1,signal2,...,signalN)
displays the frequency
spectrum of multiple signals in the spectrum analyzer. The number of channels in each
signal can be different but the frame size of each signal should be the same.
Input Arguments
signal
— Input signal or signals to visualize
scalar | vector | matrix
Input signal or signals to visualize, specified as a scalar, vector, or a matrix. The number of channels in each signal can be different but the frame size of each signal should be the same.
This scope supports variable-size input signals. That is, the frame size (number of rows) of the input signals can change during simulation, but the number of channels (number of columns) cannot change.
When you set the InputDomain
property to "time"
, the input signals can
be real or complex. When you set the InputDomain
property to
"frequency"
, the input signals must be real.
Example: scope(signal1,signal2)
Scope Window Use
To change the appearance of signals in the spectrum analyzer, click the Scope tab and then click Settings. In the spectrum analyzer Settings window, under Color and styling, select a signal and modify its style, width, color, and marker type.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Complex Number Support: Yes
Object Functions
Specific to spectrumAnalyzer
generateScript | Generate MATLAB script to create scope with current settings |
getMeasurementsData | Get the current measurement data displayed on the spectrum analyzer |
getSpectralMaskStatus | Get test results of current spectral mask |
getSpectrumData | Save spectrum data shown in spectrum analyzer |
isNewDataReady | Check spectrum analyzer for new data |
printToFigure | Print scope window to MATLAB figure |
Specific to Scopes
Note
If you want to restart the simulation from the beginning, call
reset
to clear the scope window display. 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; % Sample rate 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 = spectrumAnalyzer(SampleRate=Fs,AveragingMethod="exponential",... PlotAsTwoSidedSpectrum=false,... RBWSource="auto",SpectrumUnits="dBW"); for idx = 1:250 y1 = sin1(); y2 = sin2(); y3 = sin3(); y4 = sin4(); y5 = sin5(); scope(y1+y2+y3+y4+y5+0.0001*randn(fSz,1)); end
Call the release
function 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 noisy sine wave on the Spectrum Analyzer.
sin = dsp.SineWave(Frequency=100,SampleRate=1000,... SamplesPerFrame=1000); scope = spectrumAnalyzer(SampleRate=sin.SampleRate); for ii = 1:250 x = sin() + 0.05*randn(1000,1); scope(x); end
Call the release
function to change property values and input characteristics. The scope automatically scales the axes and updates the display one more time if the internal buffer contains any more data.
release(scope);
Run the MATLAB clear
function to close the Spectrum Analyzer window.
clear('scope');
Spectrogram of Chirp Signal
Plot 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 = spectrumAnalyzer(SampleRate=Fs,... AveragingMethod="exponential",... ForgettingFactor=0.3,ViewType="spectrogram",... RBWSource="property",RBW=500,... TimeSpanSource="property",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
Create two dsp.SpectrumEstimator
objects. Set one object to use the Welch-based spectral estimation technique with a Hann window. Set the other object to use the filter bank estimation. Specify a noisy sine wave input signal with four sinusoids at 0.16, 0.2, 0.205, and 0.25 cycles per sample. View the spectral estimate using the spectrumAnalyzer
object.
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 = 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 Measurements Data Programmatically for spectrumAnalyzer
object
Compute and display the power spectrum of a noisy sinusoidal input signal using the spectrumAnalyzer
MATLAB® object. Measure the peaks, cursor placements, adjacent channel power ratio, and distortion values in the spectrum by enabling these 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 spectrumAnalyzer
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 = spectrumAnalyzer(SampleRate=Fs,SpectrumType="power",... PlotAsTwoSidedSpectrum=false,ChannelNames={'Power spectrum of the input'},... YLimits=[-120 40],ShowLegend=true);
Enable Measurements Data
To obtain the measurements, set the Enabled
property to true
.
SA.CursorMeasurements.Enabled = true; SA.ChannelMeasurements.Enabled = true; SA.PeakFinder.Enabled = true; SA.DistortionMeasurements.Enabled = true;
Use getMeasurementsData
Stream in the noisy sine wave input signal and estimate the power spectrum of the signal using the spectrumAnalyzer
object. Measure the characteristics of the spectrum. Use the getMeasurementsData
function to obtain these measurements programmatically. The isNewDataReady
function returns true
when there is new spectrum data. Store the measured data 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 panes at the bottom of the scope window display the measurements that you have enabled. The values in these panes match the values 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
Use the PeakFinder
property to obtain peak values. Verify that the peak values in the last time step of data
match the values in the spectrum analyzer plot.
peakvalues = data.PeakFinder(end).Value
peakvalues = 3×1
26.3957
22.7830
-57.9977
frequencieskHz = data.PeakFinder(end).Frequency/1000
frequencieskHz = 3×1
4.9957
0.9905
20.6719
Print Spectrum Analyzer Scope Display to MATLAB Figure
Since R2023b
Use the printToFigure
function to print the spectrumAnalyzer
object display window to a new MATLAB® figure.
Generate a chirp signal and use the spectrumAnalyzer
object to display the spectrum of the chirp. This plot shows the default color and style settings of the spectrumAnalyzer
object.
chirp = dsp.Chirp(SweepDirection="Bidirectional", ... TargetFrequency=2000, ... InitialFrequency=0,... TargetTime=400, ... SweepTime=400, ... SamplesPerFrame=1024, ... SampleRate=4000); scope = spectrumAnalyzer(AveragingMethod="exponential",... ForgettingFactor=0,SampleRate=4000); scope(chirp());
Change the background color and the axes color of the plot to "white"
. Set the font color and line color to "black"
.
scope.BackgroundColor = "white"; scope.AxesColor = "white"; scope.FontColor = "black"; scope.LineColor = "black"; show(scope) release(scope)
Print the display of the chirp spectrum to a new MATLAB figure. The function returns a handle to the figure.
scopeFig = printToFigure(scope);
The handle to the figure scopeFig
lets you modify the appearance and the behavior of the figure window.
Specify a figure name and change the size of the figure to 400-by-250 pixels.
scopeFig.Name="Spectrum of Chirp Signal"; scopeFig.NumberTitle="off"; scopeFig.Position=[1 1 400 250];
When printing to figure, you can make the figure invisible by setting the Visible
argument to false
.
scopeFig = printToFigure(scope,Visible=false);
Limitations
Does not support C/C++ code generation using MATLAB Coder™. To generate a standalone application, use the MATLAB Compiler™.
Supports MEX code generation by treating the calls to the object as extrinsic.
More About
Convert the Power Between Units
Conversion of power between units on the Spectrum Analyzer window.
The Spectrum Analyzer provides three units to specify the power spectral density:
Watts/Hz
, dBm/Hz
, and
dBW/Hz
. Corresponding units of power are
Watts
, dBm
, and
dBW
. For electrical engineering applications, you can also view
the RMS of your signal in Vrms
, dBuV
(since R2023b), or dBV
. The
default spectrum type is Power in dBm
.
Power in dBW
is given by:
Power in dBm
is given by:
For a sine wave signal with an amplitude of 1 V, the power of a one-sided spectrum in
Watts
is given by:
Corresponding power in dBm is given by this equation.
For a white noise signal, the spectrum is flat for all frequencies. Consider a white noise signal with a variance of 1e-4. The power per unit bandwidth therefore (Punitbandwidth) is 1e-4. For a one-sided spectrum in the range [0 Fs/2], the total power of white noise in Watts
is given by this equation.
Fs is the input sample rate. The number of frequency bins is the ratio of total bandwidth to RBW. For a one-sided spectrum, the total bandwidth is half the sample rate. Consider a sample rate of 44100 Hz and a RBW of 21.53 Hz. With these values, the total power of white noise in Watts
is 0.1024 W.
In dBm, the power of white noise can be calculated using 10*log10(0.1024/10^-3), which equals 20.103 dBm.
If you set the spectral units to dBFS
and set the full scale (FullScaleSource
) to "auto"
, power in dBFS
is computed as:
where:
Pwatts
is the power in wattsFor double and float signals, Full_Scale is the maximum value of the input signal.
For fixed point or integer signals, Full_Scale is the maximum value that can be represented.
If you specify a manual full scale (set FullScaleSource
to "property"
), power in dBFS
is given by:
Where FS
is the full-scaling factor specified in the FullScale
property.
For a sine wave signal with an amplitude of 1 V, the power of a one-sided spectrum in
Watts
is given by:
The corresponding power in dBFS is given by:
To confirm the power value in the spectrum analyzer, run these commands:
Fs = 1000; % Sampling frequency sinef = dsp.SineWave(SampleRate=Fs,SamplesPerFrame=100); scope = spectrumAnalyzer(SampleRate=Fs,... SpectrumUnits="dBFS",PlotAsTwoSidedSpectrum=false) for ii = 1:100000 xsine = sinef(); scope(xsine) end
Power in dBm
is given by:
Voltage in RMS is given by:
From the previous example, PdBm equals 26.9897 dBm. The Vrms is calculated as
which equals 0.7071.
To confirm this value using the peak finder:
In the Scope Tab of the Spectrum Analyzer toolstrip, select Spectrum > RMS.
Enable Peak Finder in the Measurements tab.
Cursor Measurements
Measure signal values using vertical waveform cursors that track along the signal.
When you click the Data Cursors button in the Measurements tab of the Spectrum Analyzer, the spectrum display shows vertical cursors on each signal. Each cursor tracks a vertical line along the signal. The scope displays the difference between x- and y-values of the signal at the two cursors in the box between the cursors.
To enable cursor measurements, click the Data Cursors button in the Measurements tab. The cursors appear only when the Spectrum Analyzer has at least one signal in its display.
You can use the mouse to move the vertical cursors left and right.
In the Measurements tab, click the Data Cursors drop-down arrow to select one of these options:
Snap to Data — To position the cursors on the signal data points.
Lock Cursor Spacing — To lock the frequency difference between the two cursors.
For modifying the cursor measurements programmatically, see the CursorMeasurementsConfiguration
object.
Peak Finder Measurements
Compute and display peak values in the scope display.
When you click the Peak Finder button in the Measurements tab of the Spectrum Analyzer, an arrow appears on the plot at each maxima and a Peaks panel appears at the bottom of the scope window. The Spectrum Analyzer computes peaks from the portion of the input signal that is currently on display in the scope, and the Peaks panel shows the peak values and the frequencies at which they occur.
The Peaks section in the Measurements tab allows you to specify the number of peaks you want the scope to display, the minimum height above which you want the scope to detect peaks, the minimum distance between peaks, and label the peaks.
The Spectrum Analyzer algorithm defines a peak as a local maximum with lower values present on either side of the peak. It does not consider end points as peaks. For more information on the algorithm, see the findpeaks
function.
The peaks are valid for any units of the input signal. The letter after the value associated with each measurement indicates the abbreviation for the appropriate International System of Units (SI) prefix, such as m for milli-. For example, if the input signal is measured in volts, an m next to a measurement value indicates that this value is in units of millivolts.
For modifying the peak finder measurements programmatically, see the PeakFinderConfiguration
object. For more information on these settings in the
UI, see Peaks.
Distortion Measurements
Measure harmonic distortion and intermodulation distortion.
When you click the Distortion button in the Distortion section of the Measurements tab, a distortion panel opens at the bottom of the Spectrum Analyzer window. This panel shows the harmonic and distortion measurement values for the input signal currently on display in the scope. The Distortion section in the Measurements tab allows you to specify the distortion type, number of harmonics, and even label the harmonics.
Note
For an accurate measurement, ensure that the fundamental signal (for harmonics) or
primary tones (for intermodulation) is larger than any spurious or harmonic content. To
do so, you may need to adjust the resolution bandwidth (RBW
) of the
Spectrum Analyzer. Make sure that the bandwidth is low enough to isolate the signal and
harmonics from spurious noise content. In general, you should set the RBW value such
that there is at least a 10 dB separation between the peaks of the sinusoids and the
noise floor. You also might need to select a different spectral window to obtain a valid
measurement.
You can set the Distortion Type parameter to one of these values:
Harmonic
–– SelectHarmonic
if your input is a single sinusoid.Intermodulation
–– SelectIntermodulation
if your input is two equal-amplitude sinusoids. Intermodulation can help you determine distortion when the scope uses only a small portion of the available bandwidth.
See Distortion Measurements for information on how distortion measurements are calculated.
When you set the Distortion Type to Harmonic
,
these fields appear in the Harmonic Distortion panel at the bottom
of the Spectrum Analyzer window.
H1 — Fundamental frequency in Hz and its power in decibels of the measured power referenced to 1 milliwatt (dBm).
H2, H3, ... — Harmonics frequencies in Hz and their power in decibels relative to the carrier (dBc). If the harmonics are at the same level or exceed the fundamental frequency, reduce the input power.
THD — Total harmonic distortion. This value represents the ratio of the power in the harmonics D to the power in the fundamental frequency S. If the noise power is too high in relation to the harmonics, the THD value is not accurate. In this case, lower the resolution bandwidth or select a different spectral window.
SNR — Signal-to-noise ratio (SNR). This value represents the ratio of the power in the fundamental frequency S to the power of all nonharmonic content N, including spurious signals, in decibels relative to the carrier (dBc).
If you see
––
as the reported SNR, the total nonharmonic content of your signal is less than 30% of the total signal.SINAD — Signal-to-noise-and-distortion ratio. This value represents the ratio of the power in the fundamental frequency S to all other content (including noise N and harmonic distortion D) in decibels relative to the carrier (dBc).
SFDR — Spurious-free dynamic range (SFDR). This value represents the ratio of the power in the fundamental frequency S to power of the largest spurious signal R regardless of where it falls in the frequency spectrum. The worst spurious signal might or might not be a harmonic of the original signal. SFDR represents the smallest value of a signal that can be distinguished from a large interfering signal. SFDR includes harmonics.
The harmonic distortion measurement automatically locates the largest sinusoidal component (fundamental signal frequency). It then computes the harmonic frequencies and power in each harmonic in your signal and ignores any DC component. The measurement does not include any harmonics that are outside the Spectrum Analyzer frequency span. Adjust your frequency span so that it includes all the desired harmonics.
Note
To view the best harmonics, make sure that your fundamental frequency is set high enough to resolve the harmonics. However, this frequency should not be so high that aliasing occurs. For the best display of harmonic distortion, your plot should not show skirts, which indicate frequency leakage. The noise floor should be visible.
For a better display, try a Kaiser window with a large sidelobe attenuation (e.g. between 100–300 db).
When you set the Distortion Type to
Intermodulation
, the following fields appear in the
Intermodulation Distortion panel at the bottom of the Spectrum
Analyzer window.
F1 — Lower fundamental first-order frequency.
F2 — Upper fundamental first-order frequency.
2F1 - F2 — Lower intermodulation product from third-order harmonics.
2F2 - F1 — Upper intermodulation product from third-order harmonics.
TOI — Third-order intercept point. If the noise power is too high in relation to the harmonics, the TOI value will not be accurate. In this case, you should lower the resolution bandwidth or select a different spectral window. If the TOI has the same amplitude as the input two-tone signal, reduce the power of that input signal.
The intermodulation distortion measurement automatically locates the fundamental and the first-order frequencies (F1 and F2). It then computes the frequencies of the third-order intermodulation products (2F1−F2 and 2F2−F1).
For modifying the distortion measurements programmatically, see the DistortionMeasurementsConfiguration
object. For more information on these
settings in the UI, see Distortion.
Channel Measurements
Measure the occupied bandwidth or adjacent channel power ratio (ACPR).
When you click the Channel Measurements button in the Channel Measurements tab, a channel measurements panel opens at the bottom of the Spectrum Analyzer window. This panel displays the occupied bandwidth or the adjacent channel power ratio measurements. In the Channel Measurements tab, you can specify the occupied bandwidth or the ACPR settings, frequency span, center frequency, and start and stop frequencies.
You can select the channel measurements Type to:
Occupied BW
–– Occupied bandwidthACPR
–– Ratio of the power of the main channel to the power of the adjacent channel
For more details on how the Spectrum Analyzer calculates the occupied bandwidth, see Occupied BW.
Occupied Bandwidth
When you set the Type of channel measurement to compute and display to
Occupied BW
, these fields appear in the measurements panel at
the bottom of the scope window.
Channel Power — Total power in the channel
Occupied BW — Bandwidth containing the specified Occupied BW (%) of the total power of the spectrum.
Frequency Error — Difference between the center of the occupied band and the center frequency (Center Frequency (Hz)) of the channel
ACPR
When you set the Type of channel measurement to compute and display to
ACPR
, these fields appear in the measurements panel at the
bottom of the scope window.
Lower (Rel Power (dBc)) — Ratio of the power of the lower sideband to the power of the main channel
Upper (Rel Power (dBc)) — Ratio of the power of the upper sideband to the power of the main channel
To modify the channel measurements programmatically, see the ChannelMeasurementsConfiguration
object. For more information on these
settings in the UI, see Channel Measurements.
Spectral Mask
Visualize spectrum limits and compare spectrum values to specification values.
Add upper and lower masks to the Spectrum Analyzer to visualize spectrum limits and compare spectrum values to specification values. To enable the Spectral Mask tab, select Spectrum in the Scope tab. When you click the Upper Mask and Lower Mask buttons in the Spectral Mask tab, a Spectral Mask panel opens at the bottom of the Spectrum Analyzer window. This panel provides information on pass-fail statistics of masks, names of masks currently failing or passing, and names of channels causing the failure.
You can modify the mask settings in the Spectral Mask tab. For more
information on these settings in the UI, see Spectral Mask. For
modifying the channel measurements programmatically, see the SpectralMaskConfiguration
object.
You can check the status of the spectral mask using the getSpectralMaskStatus
function. This function gives details on the number
of times a mask succeeded or failed, names of channels causing mask failure, and so
on.
You can even use the MaskTestFailed
event to perform an action every time
the mask fails. To trigger a function when the mask fails, create a listener to the
MaskTestFailed
event and define a callback function to trigger
it. For more details about using events, see Events.
Customize Visualization
Set configuration and style settings in the Spectrum Analyzer.
To control the settings of the display and labels, color and styling, click on Settings () in the Scope tab of the Spectrum Analyzer toolstrip.
In the dialog box that opens, you can customize the font size, plot type, y-axis properties of the spectrum plot, and color map properties of the spectrogram plot. You can change the color of the spectrum plot, background, axes, and labels and also change the line properties.
When you view the spectrum or the spectrogram, you see only the relevant options. For more details about these options, see Configuration > Spectrum Settings.
Display Controls
Zoom and pan axes using display controls.
To scale the plot axes, use the mouse to pan around the axes and the scroll button on your mouse to zoom in and out of the plot. Additionally, you can use the buttons that appear when you hover over the plot window.
— Maximize the axes, hide all labels and inset the axes values.
— Zoom in on the plot.
— Pan the plot.
— Autoscale the axes to fit the shown data.
Tips
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 More About and the Algorithm 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 or the Number of frequency bands parameter to determine the input frame length.
When you specify the Resolution Method to
RBW
, and you set RBW (Hz) to:
Auto
–– 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.
The RBW value you specify must be 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 you specify the Resolution Method to Number of
frequency bands
, the resulting RBW is given by:
When the number of input samples is not sufficient to achieve the specified resolution bandwidth, the spectrum analyzer adjusts its RBW value according to the number of input samples provided and displays a message similar to this one. The spectrum analyzer removes this message 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.
If you set the Resolution Method to
Window length
, you can specify the data window length Nwindow using the Window Length parameter in the Estimation tab.If you set the Resolution Method to
RBW
, the algorithm determines the data window length using this equation, .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
periodogram
.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 uses a certain number of samples to compute a spectral estimate. This value is directly related to the resolution bandwidth (RBW) using this equation,
or to the window length (Nwindow) using this equation,
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.
When you specify the Resolution
Method to RBW
, the window length is given
by,
When you specify the Resolution
Method to Window length
, the algorithm uses
the window length value you specify in the Window Length parameter
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. Nwindow is the window length. For more information on how the algorithm determines the window length, see the Spectrum Estimation –– Welch's Method section in Algorithms.
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
Estimation 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
Scope 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. Click the icon in 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 specify the resolution bandwidth using the RBW (Hz) parameter.
If you specify the window length, the scope determines the RBW value from the window length using this equation, .
When you specify the Resolution
Method to RBW
, and you set RBW
(Hz) to:
Auto
–– 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 you specify the Resolution
Method to Number of frequency bands
, the
resulting RBW is given by:
When the number of input samples is not sufficient to achieve the specified resolution bandwidth, the spectrum analyzer adjusts its RBW value according to the number of input samples provided and displays a message similar to this one. The spectrum analyzer removes this message once you provide enough input samples.
You can enable this property in the status bar at the bottom of the spectrum analyzer
window. Click the icon in 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 THD, THD%, SINAD, SNR, 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
Version History
Introduced in R2022aR2024b: Adaptive RBW: Display spectral data for any number of input samples and adjust RBW accordingly
Previously, spectrum analyzer required a minimum number of samples to update the display for a given RBW value. Starting in R2024b, this limitation is removed. The scope now updates its display for any number of input samples and adjusts the RBW value accordingly.
R2024b: Window Invariant Samples Per Update: Adjust RBW value to always require 1024 samples per spectral update
The spectrum analyzer can now automatically adjust the resolution bandwidth (RBW) such that it always requires 1024 samples per spectral update (Nsamples = 1024) irrespective of the window you choose.
To enable this mode in the spectrumAnalyzer
object, set:
Method
to"welch"
.FrequencyResolutionMethod
to"rbw"
.RBWSource
to"auto"
.WindowInvariantSamplesPerUpdate
totrue
.
R2024b: New color and styling properties
Using the new color and styling properties, you can customize the plot line, axes, and background settings of the scope through the MATLAB command line.
R2024b: Higher display precision in scope UI
You can now increase the display precision to 15 digits using the Display Precision property in the scope settings under Display and Labels. This precision affects all the measurements and data that the scope displays on its status bar.
R2024b: Preserve Colors is now available in scope toolstrip
The Preserve colors for copy to clipboard property has been renamed to Preserve Colors and is now available in the scope toolstrip under Copy Display.
R2024a: Analyzer tab has been renamed as Scope tab
The Analyzer tab in spectrum analyzer has been renamed as Scope tab.
R2024a: Specify window length and FFT length
You can now specify the window length and FFT length in the spectrum analyzer under certain conditions. These properties are available starting R2024a:
FrequencyResolutionMethod
WindowLength
FFTLengthSource
FFTLength
R2023b: Spectrum Analyzer supports dBuV
units
You can set SpectrumUnits
to "dBuV"
when you
set:
InputDomain
to"time"
andSpectrumType
to"rms"
.InputDomain
to"frequency"
.
You can set InputUnits
to "dBuV"
when you set
InputDomain
to "frequency"
.
R2023b: Support for printToFigure
function
You can print the spectrumAnalyzer
object display window to a
MATLAB figure using the new printToFigure
function.
R2023a: SampleRate
and PlotAsTwoSidedSpectrum
properties are tunable
Starting in R2023a, the SampleRate
and
PlotAsTwoSidedSpectrum
properties are tunable, so you can change the
values of these properties even when the object is locked
.
R2022b: Channel names support array of strings
Starting in R2022b, you can specify the ChannelNames
property of
the spectrumAnalyzer
object as an array of strings.
sa = spectrumAnalyzer(ChannelNames=["Input", "Output"]);
R2022b: New FilterSharpness
property
When the object uses the filter bank spectral estimation method, you can now increase
the sharpness of the filter bank in the spectrumAnalyzer
object. Increasing the filter sharpness decreases the spectral leakage and gives a more
accurate power reading.
R2022b: New fields on Spectrum Analyzer status bar
Starting in R2022b, the Spectrum Analyzer displays these fields on the status bar:
Updates –– This field shows when you select Spectrum updates processed in the Customize Status Bar window.
Channel number –– This field shows when you select Spectrogram channel in the Customize Status Bar window.
The Spectrogram channel field is enabled only when the display shows spectrogram.
To enable these fields, right-click the status bar and select the properties in the Customize Status Bar window.
For more details, see Configure Spectrum Analyzer.
R2022b: Support for waveform cursors in spectrogram mode
Starting in R2022b, the Spectrum Analyzer supports data cursors even when the scope shows only the spectrogram display.
In the command line, you can edit the CursorMeasurementsConfiguration
object when you set the
ViewType
to "spectrogram"
.
R2022b: Enhancements to Data Cursor Measurements
Starting in R2022b, the CursorMeasurementsConfiguration
object has the new
LockSpacing
property. Using this property, you can lock the spacing
between waveform cursors in the scope window.
In the Measurements tab of the scope UI window, these data cursor settings are new:
Lock cursor spacing –– This setting corresponds to the
LockSpacing
property in theCursorMesaurementsConfiguration
object.X location –– These fields are enabled and correspond to the
XLocation
property in theCursorMesaurementsConfiguration
object.
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes 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)