Main Content

Spectrum Analyzer

Display frequency spectrum

  • Spectrum Analyzer block

Libraries:
DSP System Toolbox / Sinks
Audio Toolbox / Sinks
DSP System Toolbox HDL Support / Sinks

Description

The Spectrum Analyzer block, referred to here as the scope, displays frequency-domain signals and the frequency spectrum of time-domain signals. The scope shows the spectrum view and the spectrogram view. The block algorithm 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.

Snapshot of spectrum analyzer scope showing both the spectrum and the Spectrogram.

You can use the Spectrum Analyzer block in models running in Normal or Accelerator simulation modes. You can also use the Spectrum Analyzer block in models running in Rapid Accelerator or External simulation modes with some limitations.

You can use the Spectrum Analyzer block inside all subsystems and conditional subsystems. Conditional subsystems include enabled subsystems, triggered subsystems, enabled and triggered subsystems, and function-call subsystems. See Conditionally Executed Subsystems Overview for more information.

Measurements

Programmatic Control

Configure and display the spectrum analyzer settings from the command line with the SpectrumAnalyzerBlockConfiguration (DSP System Toolbox) object.

Examples

expand all

This example shows how to visualize frequency input signals with the Spectrum Analyzer block.

To visualize frequency-domain input signals using a Spectrum Analyzer block, in the Estimation tab of the Spectrum Analyzer toolstrip, set Input Domain to Frequency. In the Spectrum tab, clear the Two-Sided Spectrum parameter.

Run the model. You can see two peaks. To measure the peaks, enable Peak Finder in the Measurements tab.

Decimate a sinusoidal signal by varying the decimation factor using the Variable FIR Decimation (DSP System Toolbox) block. You can vary the decimation factor in the block dialog box or through an input port while the simulation is running.

Open and Inspect Model

Open the DisplayVariableSizeSignalonSpectrumAnalyzer model.

The input signal in the model is a sum of two sine waves with the frequencies of 1 kHz and 10 kHz, sample time of 1/44100 s, and contains 256 samples per frame. The Random Source block adds zero-mean white Gaussian noise with a variance of 0.05 to the sum of sine waves.

Pass this signal through the Variable FIR Decimation block. The Maximum decimation factor parameter in the block is set to 24. You can specify the decimation factor through the input port and vary it using the Manual Switch block. The output of the Variable FIR Decimation block is a variable-size signal whose frame size varies according to the decimation factor that you specify.

Run Model

Visualize the spectrum of the decimated signal in the spectrum analyzer. The sample rate of the spectrum analyzer updates based on the frame size of the signal and the sample rate of the signal.

When you set the decimation factor to 2, the output frame size is half the input frame size, and the spectrum analyzer uses a sample rate of 44100/2 or 22.05 kHz.

While the simulation is running, change the decimation factor to 4. You can see that the sample rate of the spectrum analyzer adjusts to 44100/4 or 11.025 kHz. The tone at 1 kHz remains the same while the tone at 10 kHz is no longer visible in the spectrum analyzer since the span of the spectrum is now [0 Fs/2] = [0 5.5125 kHz].

Compute and display the power spectrum of a noisy sinusoidal input signal using the Spectrum Analyzer block. Measure the cursor placements, adjacent channel power ratio, distortion, and peak values in the spectrum by enabling these block configuration properties:

  • CursorMeasurements

  • ChannelMeasurements

  • DistortionMeasurements

  • PeakFinder

Open and Inspect the Model

Filter a streaming noisy sinusoidal input signal using a Lowpass Filter block. The input signal consists of two sinusoidal tones: 1 kHz and 15 kHz. The noise is white Gaussian noise with a mean of 0 and a variance of 0.05. The sampling frequency is 44.1 kHz. Open the model and inspect the parameter values in the blocks.

model = 'spectrumanalyzer_measurements.slx';
open_system(model)

Access the configuration properties of the Spectrum Analyzer block using the get_param function.

sablock = 'spectrumanalyzer_measurements/Spectrum Analyzer';
cfg = get_param(sablock,'ScopeConfiguration');

Enable Measurements Data

To obtain the measurements, set the Enabled property to true.

cfg.CursorMeasurements.Enabled = true;
cfg.ChannelMeasurements.Enabled = true;
cfg.DistortionMeasurements.Enabled = true;
cfg.PeakFinder.Enabled = true;

Simulate the Model

Run the model. The Spectrum Analyzer block compares the original spectrum with the filtered spectrum.

sim(model)

The panes at the bottom of the spectrum analyzer window display the measurements that you have enabled.

Use getMeasurementsData function

Use the getMeasurementsData function to obtain the measurements programmatically.

data = getMeasurementsData(cfg)
data =

  1x5 table

    SimulationTime    PeakFinder    CursorMeasurements    ChannelMeasurements    DistortionMeasurements
    ______________    __________    __________________    ___________________    ______________________

        9.9962        1x1 struct        1x1 struct            1x1 struct               1x1 struct      

The values shown in the measurement panels match the values shown in data. You can access the individual fields of data to obtain the various measurements programmatically.

Compare Peak Values

As an example, compare the peak values. Verify that the peak values obtained by data.PeakFinder match with the values in the spectrum analyzer window.

peakvalues = data.PeakFinder.Value
frequencieskHz = data.PeakFinder.Frequency/1000
peakvalues =

   26.8237
   26.3370
   -5.3604


frequencieskHz =

   15.0015
    1.0049
   12.2739

Extended Examples

Ports

Input

expand all

Connect the signals you want to visualize. You can have up to 96 input ports. Input signals must have these characteristics:

The Spectrum Analyzer block supports variable-size input signals, that is, the frame size of the signals can change during simulation. When the signal frame size changes, the sample rate the scope uses changes accordingly, which in turn updates the frequency span of the spectrum display.

The Spectrum Analyzer block accepts fixed-point input, but converts it to double for display.

This port is unnamed until you enable one of these inputs ports:

  • F

  • RBW

  • VBW

(since R2024a)

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point
Complex Number Support: Yes

Specify the frequencies in Hz. The frequency vector must be a finite, monotonically increasing, column vector with two or more elements. The number of frequency vector points must be equal to the input frame size. You can also specify the frequencies using the Frequency (Hz) parameter on the Estimation tab.

Dependency

To enable this port, set the:

  • Input Domain parameter on the Estimation tab to Frequency.

  • Frequency (Hz) parameter on the Estimation tab to Input port.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point

Specify the resolution bandwidth in Hz through this port. RBW defines the smallest positive frequency that can be resolved by the scope. You can also specify the RBW value using the RBW (Hz) parameter on the Estimation tab.

Dependency

To enable this port, set the RBW (Hz) parameter on the Estimation tab to Input port.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point

Specify the video bandwidth in Hz through this port. Video bandwidth is the bandwidth of the lowpass filter that the scope uses to average or smooth the noise in the signal before displaying it. You can also specify the VBW value using the VBW (Hz) parameter on the Estimation tab.

Dependency

To enable this port, set the:

  • Input Domain parameter on the Estimation tab to Time.

  • Averaging Method parameter on the Estimation tab to VBW.

  • VBW (Hz) parameter on the Estimation tab to Input port.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point

Parameters

expand all

Scope Tab

Views

Set the type of spectrum to display as one of these values:

  • Power — Spectrum Analyzer shows the power spectrum.

  • Power Density — Spectrum Analyzer shows the power spectral density. The power spectral density is the squared magnitude of the spectrum normalized to a bandwidth of 1 Hz.

  • RMS — Spectrum Analyzer shows the root mean squared spectrum. Use this option to view the frequency of voltage or current signals.

Tunable: Yes

Dependency

To enable this parameter, set the Input Domain parameter on the Estimation tab to Time.

Programmatic Use

Block Parameter: SpectrumType
Type: character vector or string scalar

Bandwidth

Specify the sample rate the scope uses in Hz as one of the following:

  • Inherited –– Use this option to specify the same sample rate as the input signal.

  • Positive scalar –– The sample rate you specify must be at least twice the sample rate of the input signal. Otherwise, you might see unexpected behavior when visualizing your signal in the scope due to aliasing.

When the signal frame size changes, the sample rate the scopes uses changes accordingly which in turn updates the frequency span of the spectrum display.

To display the sample rate on the status bar, click the kebab icon in the right most corner of the status bar icon in the status bar and select Sample Rate.

Tunable: Yes

Programmatic Use

Block Parameter: SampleRate, SampleRateSource
Type: double

Specify the offset to apply to the frequency axis (x-axis) in units of Hz 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 Span (Hz) parameter.

Tunable: Yes

Programmatic Use

Block Parameter: FrequencyOffset
Type: double

Configuration > Spectrum Analyzer Settings (Gear button)

The number of input ports to the block, specified as an integer between 1 and 96. To change the number of input ports, drag a new input signal line to the block and the block automatically creates new ports.

Programmatic Use

Block Parameter: NumInputPorts
Type: character vector or string scalar
Values: scalar between 1 and 96

Select this parameter to automatically open the Spectrum Analyzer window when you run the simulation.

Programmatic Use

Block Parameter: OpenAtSimulationStart
Type: logical

Since R2024b

Specify the precision of numeric values in the scope display as a positive integer in the range [1, 15].

Tunable: Yes

Specify the y-axis label in the Spectrum display as a character vector or a string scalar. To display signal units, add (%<SignalUnits>) to the label. When simulation starts, Simulink replaces (%SignalUnits) with the units associated with the signals.

For example, for a velocity signal with units of m/s enter

Velocity (%<SignalUnits>)

Tunable: Yes

Dependency

To enable this parameter, select Spectrum in the Scope tab.

Programmatic Use

Block Parameter: YLabel
Type: character vector or string scalar

Specify the y-axis limits in the Spectrum Analyzer display as a two-element numeric vector of the form [ymin ymax]. The units of the y-axis limits depend on the Spectrum Unit in the Spectrum tab.

Tunable: Yes

Dependency

To enable this parameter, select Spectrum in the Scope tab.

Programmatic Use

Block Parameter: YLimits
Type: double

Specify the display title. Enter %<SignalLabel> to use the signal labels in the Simulink model as the axes titles.

Tunable: Yes

Programmatic Use

Block Parameter: Title
Type: character vector or string

Select this check box to show the grid in the Spectrum Analyzer display.

Tunable: Yes

Programmatic Use

Block Parameter: ShowGrid
Type: logical

Select a valid colormap name for the spectrogram, or enter a three-column matrix with values in the range [0,1] defining RGB triplets. For more information about colormaps, see colormap.

Tunable: Yes

Dependency

To enable this parameter, select Spectrogram in the Scope tab.

Programmatic Use

Block Parameter: Colormap
Type: character vector or string scalar

Specify the color limits of the spectrogram as a two-element numeric vector of the form [colorMin colorMax]. The units of the color limits directly depend upon the Spectrum Unit in the Spectrogram tab.

Tunable: Yes

Dependencies

To enable this parameter, select Spectrogram in the Scope tab.

Programmatic Use

Block Parameter: ColorLimits
Type: double

Specify whether to display a Line or Stem plot in the Spectrum display.

Tunable: Yes

Dependency

To enable this parameter:

  • Select Spectrum in the Scope tab.

  • Select the Normal Trace check box in the Spectrum tab.

Programmatic Use

Block Parameter: PlotType
Type: character vector or string scalar

Specify the font size of the ticks, labels, title, and measurements of the scope as a positive scalar.

Tunable: Yes

Programmatic Use

Block Parameter: -
Type: double

Specify the background color in the scope figure.

Tunable: Yes

Specify the background color of the axes.

Tunable: Yes

Specify the color of the labels, grid, and the channel names in the legend.

Tunable: Yes

Specify the channel for which you want to modify the visibility, line color, style, width, and marker properties.

Tunable: Yes

Select this check box to display the channel you have selected. If you clear this check box, the selected channel is no longer visible. You can also click the signal name in the legend to control its visibility. For more details, see Legend (DSP System Toolbox).

Tunable: Yes

Specify the line style for the selected channel.

Tunable: Yes

Specify the line width for the selected channel.

Tunable: Yes

Specify a data point marker for the selected channel. This parameter is similar to the Marker property for plots. You can choose any of the marker symbols from the drop-down list.

Tunable: Yes

Specify the line color for the selected channel.

Tunable: Yes

Configuration

Click the Legend button to enable the spectrum analyzer to display the signal legend. The legend displays the signal names from the model. For signals with multiple channels, the scope appends a channel index after the signal name. Continuous signals have straight lines before their names and discrete signals have step-shaped lines.

You can control which signals are visible using the legend. To hide a signal, in the scope legend, click the signal name. To display the signal, click the signal name again. Alternatively, you can control which signal is visible using the Visible parameter in the Spectrum Analyzer Settings (Gear button).

To display only one signal and hide all other signals, right-click the name of the signal you want the scope to display. To show all signals, press Esc.

Note

The legend displays only the first 20 signals. You cannot view or control any additional signals from the legend.

Tunable: Yes

Dependency

To enable the Legend, select Spectrum in the Scope tab.

Programmatic Use

Block Parameter: ShowLegend
Type: logical

When you select the Colorbar button, the spectrum analyzer shows the color bar.

Tunable: Yes

Dependencies

To enable the Colorbar button, select Spectrogram in the Scope tab.

Programmatic Use

Block Parameter: ShowColorbar
Type: logical

Stack axes vertically or horizontally by selecting the appropriate configuration in the layout grid.

Tunable: Yes

Dependencies

To enable the Layout, select Spectrum and Spectrogram in the Scope tab.

Programmatic Use

Block Parameter: AxesLayout
Type: character vector or string scalar

Share

Click this button to copy the scope display to the clipboard. You can preserve the color in the display by selecting Preserve Colors in the Copy Display drop down.

When you copy the display to the clipboard using the Copy Display and the Print options in the Scope tab > Share section, select this parameter for the scope to preserve the colors.

To access Preserve Colors, click the drop-down arrow for Copy Display.

Tunable: Yes

Click this button to save the scope display as an image or a PDF or to print the display.

Estimation Tab

Domain

The domain of the input signal you want to visualize. If you visualize time-domain signals, the scope transforms the signal to the frequency spectrum based on the algorithm you specify in the Estimation Method parameter.

Programmatic Use

Block Parameter: InputDomain
Type: character vector or string scalar

Set the frequency vector which determines the x-axis of the display to one of these values:

  • Auto — The scope calculates the frequency vector from the length of the input. For more details, see Frequency Vector.

  • Input port — You specify the frequency vector at the Frequency input port on the block.

  • Custom vector — You specify a custom vector as the frequency vector. The length of the custom vector must be equal to the frame size of the input signal.

Tunable: Yes

Dependency

To enable this parameter, set Input Domain to Frequency.

Programmatic Use

Block Parameter: FrequencyVectorSource, FrequencyVector
Type: character vector, string scalar, double

Select the units of the frequency-domain input. This parameter enables the spectrum analyzer to scale frequency data when you select a different display unit in the Spectrum Unit parameter in the Estimation tab.

Tunable: Yes

Dependency

To enable this parameter, set Input Domain to Frequency.

Programmatic Use

Block Parameter: InputUnits
Type: character vector or string scalar

Frequency Resolution

Select the spectrum estimation method 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, 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 use this parameter, set Input Domain to Time.

Programmatic Use

Block Parameter: Method
Type: character vector or string scalar

Since R2024a

Specify the frequency resolution method of the spectrum analyzer as one of these options:

  • RBW –– The RBW (Hz) parameter controls the frequency resolution (in Hz) of the analyzer.

  • Number of frequency bands –– Applies only when you set Estimation Method to Filter bank. The FFT Length parameter controls the frequency resolution.

  • Window length –– Applies only when you set Estimation Method to Welch. The Window Length parameter controls the frequency resolution.

Tunable: Yes

Dependency

To enable this parameter, set Input Domain to Time.

Programmatic Use

Block Parameter: FrequencyResolutionMethod
Type: character vector or string scalar

Specify the sharpness of the prototype lowpass filter 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 parameter, set Estimation Method to Filter bank.

Programmatic Use

Block Parameter: FilterSharpness
Type: double

Specify the resolution bandwidth in Hz. This parameter defines the smallest positive frequency that can be resolved by the scope. By default, this parameter is set to Auto. In this case, the spectrum analyzer determines the appropriate value to ensure that there are 1024 RBW intervals over the specified frequency span.

If you set this parameter to Input port, you can specify the RBW value through an input port on the block.

If you set this parameter to a numeric value, the value must allow at least two RBW intervals over the specified frequency span. In other words, the ratio of the overall frequency span to RBW must be greater than two:

spanRBW>2

To display this property on the status bar, click the kebab icon in the right most corner of the status bar icon in the status bar and select RBW.

Tunable: Yes

Programmatic Use

Block Parameter: RBWSource, RBW
Type: character vector, string scalar, double

Since R2024a

Specify the window length in samples as an integer greater than 2. The block uses the window length to compute the spectral estimates. This parameter controls the frequency resolution.

Tunable: Yes

Dependencies

To enable this parameter, set:

  • Estimation Method to Welch.

  • Resolution Method to Window Length.

Programmatic Use

Block Parameter: WindowLength
Type:double

Since R2024a

You can set the FFT length to one of these options:

  • Auto –– The value of FFT length depends on the setting of the frequency resolution method. When you set:

    • Resolution Method to RBW, the FFT length equals the number of samples per update, Nsamples. For more details on Nsamples, see the Algorithms section.

    • Resolution Method to Window length, the FFT length equals the value you specify in the Window length parameter or 1024, whichever is larger.

    • Resolution Method to Number of frequency bands, the FFT length equals the input frame size (number of rows).

  • Positive integer –– The number of FFT points equals the value you specify in the FFTLength property.

Tunable: Yes

Dependencies

To enable this parameter, set:

  • Estimation Method to Welch.

  • Estimation Method to Filter bank and Resolution Method to Number of frequency bands.

Programmatic Use

Block Parameter: FFTLengthSource, FFTLength
Type:character vector or string scalar, double

Averaging

Specify the smoothing method as one of the following:

  • VBW — Video bandwidth method. The block uses a lowpass filter to smooth the trace and decrease the noise. Use the VBW (Hz) parameter to specify the video bandwidth (VBW) value.

  • Exponential — Weighted average of samples. The block computes the average over samples weighted by an exponentially decaying forgetting factor. Use the Forgetting Factor parameter to specify the weighted forgetting factor.

For more information on the averaging methods, see Averaging Method.

Tunable: Yes

Dependency

To enable this parameter, set Input Domain to Time.

Programmatic Use

Block Parameter: AveragingMethod
Type: character vector or string scalar

Specify the video bandwidth as one of the following: S

  • Auto –– The spectrum analyzer adjusts the VBW such that the equivalent forgetting factor is 0.9.

  • Input port –– You specify the frequency vector at the VBW input port on the block.

  • Positive scalar –– You specify a positive scalar. The spectrum analyzer adjusts the VBW using this value. The value you specify must be less than or equal to Sample Rate (Hz)/2.

For more details on the video bandwidth method, see Averaging Method.

The spectrum analyzer shows the VBW value in the status bar at the bottom of the display. To display the VBW value, click the kebab icon in the right most corner of the status bar icon in the status bar and select VBW.

Tunable: Yes

Dependency

To enable this parameter, set:

  • Input Domain to Time.

  • Averaging Method to VBW.

Programmatic Use

Block Parameter: VBWSource, VBW
Type: double

Specify the forgetting factor of the exponential weighted averaging method as a scalar in the range [0,1].

Tunable: Yes

Dependency

To enable this parameter, set:

  • Input Domain to Time.

  • Averaging Method to Exponential.

Programmatic Use

Block Parameter: ForgettingFactor
Type: double

Frequency Options

Specify the frequency span mode 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 the Span (Hz) and Center Frequency (Hz) parameters.

  • Start and Stop Frequencies –– The spectrum analyzer computes and plots the spectrum over the interval specified by the Start Frequency (Hz) and Stop Frequency (Hz) parameters.

Tunable: Yes

Dependency

To enable this parameter, set Input Domain to Time.

Programmatic Use

Block Parameter: FrequencySpan
Type: character vector or string scalar

Specify the frequency span in Hz over which the spectrum analyzer computes and plots the spectrum. The overall span, defined by this parameter and the Center Frequency (Hz) parameter, must fall within the Nyquist Frequency Interval. This parameter defines the range of the values shown on the Frequency axis in the spectrum analyzer window.

Tunable: Yes

Dependency

To enable this parameter, set:

  • Input Domain to Time.

  • Frequency Span to Span and Center Frequency.

Programmatic Use

Block Parameter: Span
Type: double

Specify the center of the frequency span in Hz over which the spectrum analyzer computes and plots the spectrum. Use this parameter with the Span (Hz) parameter to define the frequency span around a center frequency. This parameter defines the midpoint of the Frequency axis in the spectrum analyzer window.

Tunable: Yes

Dependency

To enable this parameter, set:

  • Input Domain to Time.

  • Frequency Span to Span and Center Frequency.

Programmatic Use

Block Parameter: CenterFrequency
Type: double

Specify the starting frequency in Hz of the frequency interval over which the spectrum analyzer computes and plots the spectrum. The overall span, which is defined by this parameter and the Stop Frequency (Hz) parameter, must fall within the Nyquist Frequency Interval. This parameter defines the leftmost value on the Frequency axis in the spectrum analyzer window.

Tunable: Yes

Dependency

To enable this parameter, set:

  • Input Domain to Time.

  • Frequency Span to Start and Stop Frequencies.

Programmatic Use

Block Parameter: StartFrequency
Type: double

Specify the stop frequency in Hz of the frequency interval over which the spectrum analyzer computes and plots the spectrum. The overall span, which is defined by this parameter and the Start Frequency (Hz) parameter, must fall within the Nyquist Frequency Interval. This parameter defines the rightmost value on the Frequency axis in the spectrum analyzer window.

Tunable: Yes

Dependency

To enable this parameter, set:

  • Input Domain to Time.

  • Frequency Span to Start and Stop Frequencies.

Programmatic Use

Block Parameter: StopFrequency
Type: double

Window Options

Specify the windowing method to apply to the spectrum. Windowing is used to control the effect of sidelobes in spectral estimation. The window you specify affects the window length required to achieve a resolution bandwidth and the required number of samples per update. For more information about windowing, see Windows (Signal Processing Toolbox).

You can use your own spectral estimation window by directly specifying a custom window function name in the Window parameter.

Tunable: Yes

Dependency

To enable this parameter, set:

  • Input Domain to Time.

  • Estimation Method to Welch.

Programmatic Use

Block Parameter: Window, CustomWindow
Type: character vector or string scalar

Specify the sidelobe attenuation in dB as a scalar greater than or equal to 45.

Tunable: Yes

Dependency

To enable this parameter, set Window to Chebyshev or Kaiser.

Programmatic Use

Block Parameter: SidelobeAttenuation
Type: double

Specify the percentage of overlap between the previous and the current buffered data segments as a scalar in the range [0 100). The overlap creates a window segment that the scope uses to compute a spectral estimate. The value must be greater than or equal to zero and less than 100.

Tunable: Yes

Dependency

To enable this parameter, set:

  • Input Domain to Time.

  • Estimation Method to Welch.

Programmatic Use

Block Parameter: OverlapPercent
Type: double

Measurements Tab

Channel

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

Dependency

To enable this parameter, pass some data through the scope.

Programmatic Use

See MeasurementChannel (DSP System Toolbox).

Cursors

Click the Data Cursors button to enable data cursor measurements. 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.

Tunable: Yes

Programmatic Use

See Enabled (DSP System Toolbox).

Select this parameter to position the cursors on the signal data points.

Tunable: Yes

Programmatic Use

See SnapToData (DSP System Toolbox).

Select this parameter to lock the frequency difference between the two cursors.

Tunable: Yes

Programmatic Use

See LockSpacing (DSP System Toolbox).

Peaks

Click the Peak Finder button to enable peak finder measurements. An arrow appears on the plot at each maxima and a Peaks panel appears at the bottom of the scope window.

Tunable: Yes

Programmatic Use

See Enabled (DSP System Toolbox).

Specify the maximum number of peaks to show as a positive integer less than 100.

Tunable: Yes

Programmatic Use

See NumPeaks (DSP System Toolbox).

Specify the level above which the scope detects peaks as a real scalar.

Tunable: Yes

Programmatic Use

See MinHeight (DSP System Toolbox).

Specify the minimum number of samples between adjacent peaks as a positive integer.

Tunable: Yes

Programmatic Use

See MinDistance (DSP System Toolbox).

Specify the minimum difference between the height of the peak and its neighboring samples as a nonnegative scalar.

Tunable: Yes

Programmatic Use

See Threshold (DSP System Toolbox).

Click the Label Peaks button to label the peaks. The scope displays the labels (P1, P2, …) above the arrows in the plot.

Tunable: Yes

Programmatic Use

See LabelPeaks (DSP System Toolbox).

Distortion

Click the Distortion button to enable distortion measurements. A Distortion panel appears at the bottom of the scope window when you click this button.

Tunable: Yes

Programmatic Use

See Enabled (DSP System Toolbox).

Specify the type of measurement data to display as Harmonic or Intermodulation. For more details, see Distortion Measurements.

Tunable: Yes

Programmatic Use

See Type (DSP System Toolbox).

Specify the number of harmonics to measure as a positive integer less than or equal to 99.

Tunable: Yes

Dependency

To enable this parameter, set Distortion Type to Harmonic.

Programmatic Use

See NumHarmonics (DSP System Toolbox).

When you select this parameter, the spectrum analyzer adds numerical labels to harmonics in the spectrum display.

Tunable: Yes

Programmatic Use

See LabelValues (DSP System Toolbox).

When you select this parameter, the spectrum analyzer adds numerical labels to the first-order intermodulation product and third-order frequencies in the spectrum analyzer display.

Tunable: Yes

Programmatic Use

See LabelValues (DSP System Toolbox).

Spectrum Tab

Note

This tab appears when you select Spectrum in the Scope tab.

Trace Options

Select this check box to enable a two-sided spectrum view. In this view, the spectrum analyzer shows both negative and positive frequencies. When the input signal is complex-valued, you must select this parameter. If you clear this check box, the spectrum analyzer shows a one-sided spectrum with positive frequencies only. In this case, the input signal data must be real valued.

When you clear this check box, the spectrum analyzer uses power folding. The y-axis values are twice the amplitude that they would be if you were to select this parameter, except at 0 and the Nyquist frequency. A one-sided power spectral density (PSD) contains the total power of the signal in the frequency interval from DC to half the Nyquist rate. For more information, see pwelch (Signal Processing Toolbox).

Tunable: Yes

Programmatic Use

Block Parameter: PlotAsTwoSidedSpectrum
Type: logical

When you select this check box, the spectrum analyzer calculates and plots the power spectral estimates. The spectrum analyzer performs a smoothing operation by averaging several spectral estimates and continues its spectral computations even when you clear this parameter.

Tunable: Yes

Dependencies

To clear this check box, first select either the Max-Hold Trace or the Min-Hold Trace parameters.

To enable this parameter, select Spectrum in the Scope tab.

Programmatic Use

Block Parameter: PlotNormalTrace
Type: logical

Select this check box to enable the spectrum analyzer to plot the maximum spectral values of all the estimates. 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 clear this check box, the spectrum analyzer resets its maximum-hold computations.

Tunable: Yes

Dependency

To enable this parameter, select Spectrum in the Scope tab.

Programmatic Use

Block Parameter: PlotMaxHoldTrace
Type: logical

Select this check box to enable the spectrum analyzer to plot the minimum spectral values of all the estimates. 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 clear this check box, the spectrum analyzer resets its minimum-hold computations.

Tunable: Yes

Dependency

To enable this parameter, select Spectrum in the Scope tab.

Programmatic Use

Block Parameter: PlotMinHoldTrace
Type: logical

Scale

Specify the scale to display frequencies as Linear or Log. When the frequency span contains negative frequency values, you cannot choose the logarithmic option.

Tunable: Yes

Dependency

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 the Frequency Scale parameter is set to Linear.

Programmatic Use

Block Parameter: FrequencyScale
Type: character vector or string scalar

Specify the reference load in ohms that the Spectrum Analyzer uses as a reference to compute the power values.

Tunable: Yes

Dependency

To enable this parameter, set:

  • Spectrum type to Power or Power Density.

Programmatic Use

Block Parameter: ReferenceLoad
Type: double

Specify the units in which the spectrum analyzer displays the power values 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 units available depend on the value you choose for the Spectrum parameter in the Scope tab.

Estimation tab > Input Domain parameterScope tab > Spectrum optionAvailable Units
TimePowerdBm, dBW, dBFS, Watts
Power DensitydBm/Hz, dBW/Hz,dBFS/Hz, Watts/Hz
RMSdBuV (since R2023b), dBV, Vrms
FrequencyAuto, dBm, dBuV (since R2023b), dBV, dBW, Vrms, Watts

If you set the Input Domain parameter to Frequency and the Spectrum Unit parameter to Auto, the spectrum analyzer assumes the spectrum units to be equal to input units specified in the Estimation tab > Input Unit parameter. If you set the Input Domain parameter to Time and the Spectrum Unit parameter to any option other than Auto, the spectrum analyzer converts the units specified in the Input Unit parameter to the units specified in the Spectrum Unit parameter.

Programmatic Use

Block Parameter: SpectrumUnits
Type: character vector or string scalar

The full scale used for the decibel full scale (dBFS) units. By default, the spectrum analyzer uses the entire spectrum scale. Specify a positive real scalar for the dBFS full scale.

Tunable: Yes

Dependencies

To enable this parameter:

  • In the Scope tab, set the spectrum type to Power or Power Density.

  • In the Estimation tab, set Input Domain to Time.

  • In the Spectrum tab, set Spectrum Unit to dBFS or dBFS/Hz (when spectrum type is set to Power Density).

Programmatic Use

Block Parameter: FullScale
Type: double

Spectrogram Tab

Note

This tab appears when you select Spectrogram in the Scope tab.

Channel

Select the signal channel for which the spectrogram settings apply.

Tunable: Yes

Dependency

To enable this parameter, select Spectrogram in the Scope tab.

Programmatic Use

Block Parameter: SpectrogramChannel
Type: character vector, string scalar, double

Time Options

Time resolution is the amount of data, in seconds, used to compute a spectrogram line. The minimum attainable resolution is the amount of time it takes to compute a single spectral estimate. The tooltip displays the minimum attainable resolution given the current spectrum analyzer settings.

When you set RBW (Hz) and Time Resolution (s) to Auto, then the spectrum analyzer adjusts the RBW value such that there are 1024 RBW intervals in one frequency span and sets the time resolution is set to 1/RBW.

When you set RBW (Hz) to Auto and Time Resolution (s) to a positive scalar, then time resolution becomes the main control and RBW is set to 1/Time Resolution (s) Hz.

When you set RBW (Hz) to a positive scalar and Time Resolution (s) to Auto, then RBW becomes the main control and the time resolution is set 1/RBW (Hz) s.

When you set RBW (Hz) and Time Resolution (s) to a positive value, then time resolution must be equal to or larger than the minimum attainable time resolution defined by 1/RBW (Hz). Several spectral estimates are combined into one spectrogram line to obtain the desired time resolution. Interpolation is used to obtain time resolution values that are not integer multiples of 1/RBW (Hz).

Tunable: Yes

Dependency

To enable this parameter, select Spectrogram in the Scope tab and set Input Domain to Time in the Estimation tab.

Programmatic Use

Block Parameter: TimeResolutionSource, TimeResolution
Type: character vector, string scalar, double

The time span over which the spectrum analyzer displays the spectrogram specified as a positive scalar in seconds. The time span is the product of the desired number of spectral lines and the time resolution. When you set this parameter to Auto, the spectrogram displays 100 spectrogram lines at any given time. Otherwise, the spectrogram uses the time duration you specify in this parameter. 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 parameter, select Spectrogram in the Scope tab and set Input Domain to Time in the Estimation tab.

Programmatic Use

Block Parameter: TimeSpanSource, TimeSpan
Type: character vector, string scalar, double

Trace Options

Select this check box to enable a two-sided spectrum view. In this view, the spectrum analyzer shows both negative and positive frequencies. When the input signal is complex-valued, you must select this parameter. If you clear this check box, the spectrum analyzer shows a one-sided spectrum with positive frequencies only. In this case, the input signal data must be real valued.

When you clear this check box, the spectrum analyzer uses power folding. The y-axis values are twice the amplitude that they would be if you were to select this parameter, except at 0 and the Nyquist frequency. A one-sided power spectral density (PSD) contains the total power of the signal in the frequency interval from DC to half the Nyquist rate. For more information, see pwelch (Signal Processing Toolbox).

Tunable: Yes

Programmatic Use

Block Parameter: PlotAsTwoSidedSpectrum
Type: logical

Spectral Mask Tab

Note

This tab appears when you select Spectrum in the Scope tab and set the Spectrum type to be Power or Power Density.

Views

Select Upper Mask to display the upper mask in the spectrum plot. The Spectral Mask panel appears at the bottom of the spectrum analyzer window and displays mask details, such as number of times a mask succeeded, number of times a mask failed, channels causing the mask failure, and so on.

Use the Upper Limits parameter to specify the upper mask. If the entire spectrum plot is below the upper mask, the upper mask looks green. In all other cases, the upper mask looks red.

Tunable: Yes

Programmatic Use

See EnabledMasks (DSP System Toolbox).

Select Lower Mask to display the lower mask in the spectrum plot. The Spectral Mask panel appears at the bottom of the spectrum analyzer window and displays mask details, such as number of times a mask succeeded, number of times a mask failed, channels causing the mask failure, and so on.

Use the Lower Limits parameter to specify the lower mask. If the entire spectrum plot is above the lower mask, the lower mask looks green. In all other cases, the lower mask looks red.

Tunable: Yes

Programmatic Use

See EnabledMasks (DSP System Toolbox).

Configuration

Specify the limit for the upper spectral mask as a scalar or a two-column matrix.

If UpperMask is a scalar, the upper limit mask uses the same power value for all frequencies specified in the spectrum analyzer.

If you specify a matrix, the first column contains the frequency values (Hz), which correspond to the x-axis values. The second column contains the power values, which correspond to the associated y-axis values.

To apply offsets to the power and frequency values, use the Reference Level (dBr) and the Frequency Offset (Hz) parameters.

Tunable: Yes

Programmatic Use

See UpperMask (DSP System Toolbox).

Specify the limit for the lower spectral mask as a scalar or a two-column matrix.

If LowerMask is a scalar, the lower limit mask uses the same power value for all frequencies specified in the spectrum analyzer.

If you specify a matrix, the first column contains the frequency values (Hz), which correspond to the x-axis values. The second column contains the power values, which correspond to the associated y-axis values.

To apply offsets to the power and frequency values, use the Reference Level (dBr) and the Frequency Offset (Hz) parameters.

Tunable: Yes

Programmatic Use

See LowerMask (DSP System Toolbox).

Specify the reference level for mask power values as a numeric scalar or set it to Spectrum peak.

When you set Reference Level (dBr) to a scalar value, the spectrum analyzer uses this value as the reference to the power values (in dBr) for the upper mask and the lower mask of the spectrum analyzer. The reference level should have the same units as the Spectrum Unit parameter in the Spectrum tab.

When you set Reference Level (dBr) to Spectrum peak, the spectrum analyzer uses the peak value of the current spectrum of the Channel in the Spectral Mask tab as the reference power value.

Tunable: Yes

Programmatic Use

See ReferenceLevel (DSP System Toolbox) and CustomReferenceLevel (DSP System Toolbox).

Select the input channel which the spectrum analyzer uses to determine the mask reference level. The peak value of the spectrum in this channel becomes the mask reference level when you set the Reference Level (dBr) parameter to Spectrum peak.

Tunable: Yes

Dependency

To enable this parameter, set Reference Level (dBr) to Spectrum peak and display some data on the scope.

Programmatic Use

See SelectedChannel (DSP System Toolbox).

Specify the frequency offset in Hz as a finite numeric scalar. Using this value, the spectrum analyzer offsets the frequency values in the Upper Mask and the Lower Mask parameters.

Tunable: Yes

Programmatic Use

See MaskFrequencyOffset (DSP System Toolbox).

Channel Measurements Tab

Note

This tab appears when you select Spectrum in the Scope tab.

Channel

Specify the channel over which the spectrum analyzer computes and displays the occupied bandwidth and adjacent channel power ratio as a positive integer in the range [1 N], where N is the number of input channels.

Tunable: Yes

Dependency

To enable this parameter, pass data through the scope.

Programmatic Use

See MeasurementChannel (DSP System Toolbox).

Channel Measurements

Click Channel Measurements to enable channel measurements.

Tunable: Yes

Programmatic Use

See Enabled (DSP System Toolbox).

Specify the type of measurement data to display as Occupied BW or ACPR.

Tunable: Yes

Programmatic Use

See Type (DSP System Toolbox).

Specify the percentage of power over which the spectrum analyzer computes the occupied bandwidth as a positive scalar.

Tunable: Yes

Dependency

To enable this parameter, set Type to Occupied BW.

Programmatic Use

See PercentOccupiedBW (DSP System Toolbox).

Frequency Options

Specify the frequency span mode as one of the following:

  • Span and Center Frequency –– Measure over a frequency range specified in Span (Hz) and around the frequency value specified in Center Frequency (Hz).

  • Start and Stop Frequencies –– Measure over the frequency range [Start Frequency (Hz), Stop Frequency (Hz)].

Tunable: Yes

Programmatic Use

See FrequencySpan (DSP System Toolbox).

Specify the frequency span over which the spectrum analyzer computes the channel measurements as a positive scalar in Hz.

Tunable: Yes

Dependency

To enable this parameter, set Frequency Span to Span and Center Frequency.

Programmatic Use

See Span (DSP System Toolbox).

Center frequency of the span over which the object computes the channel measurements, specified as a real scalar in Hz.

Tunable: Yes

Dependency

To enable this parameter, set Frequency Span to Span and Center Frequency.

Programmatic Use

See CenterFrequency (DSP System Toolbox).

Specify the start frequency in Hz over which the spectrum analyzer computes the channel measurements.

Tunable: Yes

Dependency

To enable this parameter, set Frequency Span to Start and Stop Frequencies.

Programmatic Use

See StartFrequency (DSP System Toolbox).

Specify the stop frequency in Hz over which the spectrum analyzer computes the channel measurements.

Tunable: Yes

Dependency

To enable this parameter, set Frequency Span to Start and Stop Frequencies.

Programmatic Use

See StopFrequency (DSP System Toolbox).

Adjacent Channels

Specify the number of adjacent channel pairs as a positive integer in the range [1, 12].

Tunable: Yes

Dependency

To enable this parameter, set Type to ACPR.

Programmatic Use

See NumOffsets (DSP System Toolbox).

Specify the frequency of the adjacent channel relative to the center frequency of the main channel as a real vector of length equal to the number of offset pairs specified in Num Pairs.

Tunable: Yes

Dependency

To enable this parameter, set Type to ACPR.

Programmatic Use

See ACPROffsets (DSP System Toolbox).

Specify the adjacent channel bandwidth in Hz as a positive scalar.

Tunable: Yes

Dependency

To enable this parameter, set Type to ACPR.

Programmatic Use

See AdjacentBW (DSP System Toolbox).

Specify the filter shape for the main and adjacent channels as None, RRC, or Gaussian.

Tunable: Yes

Dependency

To enable this parameter, set Type to ACPR.

Programmatic Use

See FilterShape (DSP System Toolbox).

Specify the roll-off factor as a real scalar in the range [0, 1].

Tunable: Yes

Dependency

To enable this parameter, set Type to ACPR and Filter Shape to RRC.

Programmatic Use

See FilterCoeff (DSP System Toolbox).

Specify the BT product as a real scalar in the range [0, 1].

Tunable: Yes

Dependency

To enable this parameter, set Type to ACPR and Filter Shape to Gaussian.

Programmatic Use

See FilterCoeff (DSP System Toolbox).

Property Inspector Only

Input channel names, specified as a character vector, string, or array. The names appear in the legend, Settings, and Measurements panels. If you do not specify the names, the scope labels the channels as Channel 1, Channel 2, etc.

Example: ["A","B"]

Dependency

To see channel names, select Legend in the Scope tab.

Programmatic Use

Block Parameter: ChannelNames
Type: cell array of character vectors or string array

  • Auto — If you have not specified Title and Y-Label, the scope maximizes all plots.

  • On — The scope maximizes all plots and hides all values in Title and Y-label.

  • Off — The scope does not maximize plots.

Hover over the Spectrum Analyzer to see the maximize axes button .

Tunable: Yes

Programmatic Use

Block Parameter: MaximizeAxes
Type: character vector or string scalar

  • OnceAtStop — Scale y-axis after simulation completes.

  • Manual — Manually scale y-axis range with the Scale Y-axis Limits toolbar button.

  • Auto — Scale y-axis range during and after simulation.

  • Updates — Scale y-axis after the number of time steps specified in the Number of Updates text box (100 by default). Scaling occurs only once during each run.

Tunable: Yes

Programmatic Use

Block Parameter: AxesScaling
Type: character vector or string scalar

Set this property to delay auto scaling the y-axis.

Tunable: Yes

Dependency

To enable this property, set Axes Scaling to Updates.

Programmatic Use

Block Parameter: AxesScalingNumUpdates
Type: character vector or string scalar
Values: scalar

Block Characteristics

Data Types

Boolean | double | enumerated | fixed point | half | integer | single

Direct Feedthrough

no

Multidimensional Signals

yes

Variable-Size Signals

yes

Zero-Crossing Detection

no

More About

expand all

Algorithms

expand all

Extended Capabilities

Version History

Introduced in R2014b

expand all

See Also

Objects

Functions

Blocks