Main Content

Configure Spectrum Analyzer

R2026b

When you use the spectrumAnalyzer object in MATLAB® or the Spectrum Analyzer block in Simulink®, you can configure many settings and tools from the interface. These sections show you how to use the spectrum analyzer interface and the tools available.

Signal Display

This figure highlights the important aspects of the spectrum analyzer window in MATLAB.

This figure highlights the simulation controls you see in the Simulink version of the spectrum analyzer window.

  • Toolstrip

    The spectrum analyzer toolstrip is located at the top of the spectrum analyzer window and contains all the settings and controls. Use these settings to control the spectrum analyzer display.

    The toolstrip contains these tabs:

    • Home tab contains all the general settings for the spectrum and spectrogram display.

    • Estimation tab contains settings that control the frequency resolution and spectral averaging.

    • Measurements tab contains settings to control the various measurements supported by the scope.

    Use the pin button to keep the toolstrip showing or the arrow button to hide the toolstrip.

  • Legend –– If the input signal has multiple channels, the scope uses an index number to identify each channel of the signal. For example, the legend for a two-channel signal displays the default names as Channel 1 and Channel 2.

    To enable or disable the legend, click in the spectrum display.

    By default, the axes background in the scope is black, and the scope chooses line colors for each channel in a manner similar to the Scope (Simulink) block. When the axes background is black, the scope assigns each channel of each input signal a line color in the order shown in the legend.

    When the background is black, the default colors of the input channels are yellow, blue, orange, green, purple, teal, and pink.

    If there are more than seven channels, then the scope repeats this order when assigning line colors to the remaining channels. When the axes background is a color other than black, the scope assigns line colors in this order.

    When the background is not black, the default colors of the input channels are dark blue, orange, dark yellow, purple, green, light blue, and maroon.

    To choose line colors or background colors, click Settings () in the Home tab of the spectrum analyzer toolstrip. Under Color and Styling, use Background to change the background color of the scope, and Axes to change the background of the plot. Click Line to choose channel, and Color to change the line color of the selected channel.

  • Title, Y-Label, Y-Limits, Color Limits — You can customize the title, y-axis label, y-axis limits, and the color limits (in spectrogram view) from Settings () or by using the Title, YLabel, YLimits, and ColorLimits properties.

    The x-axis is always a frequency axis. The x-axis label is therefore either Frequency (Hz) or Frequency (kHz).

  • Min X-Axis, Max X-Axis –– Spectrum Analyzer determines the x-axis limits based on the value of the FrequencySpan property in the spectrumAnalyzer object or the SpectrumAnalyzerBlockConfiguration object (in case of the block). To change the x-axis limits in the spectrum analyzer interface, in the Home tab, click the Frequency Span drop-down arrow, and select a Frequency Span option.

  • 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.

  • Status — Provides the current status of the plot. The status can be:

    • Processing

      • Object –– Occurs after you run the object and before you run the release function

      • Block –– Occurs during simulation.

    • Stopped

      • Object –– Occurs after you call release.

      • Block –– Occurs before and after the simulation

    • Ready

      • Object –– Occurs after you construct the scope object and before you first call the object.

      • Block –– Occurs after you open the scope and before you first run a simulation.

    • Paused

      • Block –– Occurs when you pause the simulation.

  • Status Bar –– The status bar shows several signal display properties and the display time.

    For the scope to display these properties in the status bar, right-click the status bar and select the properties in the Customize Status Bar window. For more details on these properties, refer to the spectrumAnalyzer object and the Spectrum Analyzer block pages.

    Display Time –– The display time is the amount of time that has progressed since the last update to the Spectrum Analyzer display.

    Every time you call the scope, the simulation time increases by the number of rows in the input signal divided by the sample rate, as given by this equation:

    tsim=tsim−1+length(0:length(xsine))−1SampleRate

    At the beginning of a simulation, you can modify the Sample Rate (Hz) parameter on the Home tab of the spectrum analyzer toolstrip. You can also set the sample rate using the SampleRate property in the spectrumAnalyzer object or the SpectrumAnalyzerBlockConfiguration object (in case of the block). The display time is updated each time the display is updated.

    The spectrum analyzer status bar can further display one of these:

    • Frames processed

    • Samples processed

    • Spectrum updates processed

    When you enable the spectrogram display, you can show the name of the spectrogram channel in the status bar by selecting Spectrogram Channel.

Home Tab

The Home tab contains these sections.

  • Views –– Choose to view a spectrum, a spectrogram, or both. Select the type of spectrum using the Spectrum Type parameter. The spectrum analyzer updates the display accordingly.

  • Bandwidth –– Specify the input domain, sample rate, and the frequency span options.

  • Scale –– Specify the spectrum type, unit, and the scale options.

  • Export –– Save the spectrum analyzer for future use or share it with others using the Export options in this section.

    • (Object only) Generate Script –– Generate a MATLAB script to create a spectrum analyzer with the current settings. For more information on generating a script, see generateScript.

    • Print –– Opens a print dialog box from which you can print out the plot image.

    • Print to Figure –– Print the scope window to a MATLAB figure.

    • Copy to Clipboard –– Copy the display to your clipboard. You can paste the image in another program to save or share.

    • Preserve Colors –– Preserve colors while copying to the clipboard.

  • Snapshot — During a simulation, use the Snapshot button to pause the visualization at an interesting point so you can take a screenshot of the spectrum analyzer window.

Estimation Tab

The Estimation tab contains these sections.

  • Frequency Resolution –– Select the spectral estimation method as Filter bank or Welch. For more information on these methods, see Algorithms in the spectrumAnalyzer object page.

  • Averaging –– Select the method of averaging the power spectral estimate as VBW (video bandwidth) or Exponential. For more details, see Averaging Method.

Measurements Tab

The Measurements tab contains these sections.

  • Measurements section contains settings related to the data cursors, peak finder, distortion, and channel measurements.

    For more information, see:

  • Spectral Mask — Enable to show upper and lower masks in the spectrum analyzer. You can specify the upper and lower limits of the mask, and select the channel over which the spectrum analyzer applies the mask. For more information, see Spectral Mask.

See Also

Objects

Blocks

Topics