Display frequency spectrum
Simscape / Utilities
Note
The Spectrum Analyzer block in the Simscape™ product contains a subset of functionality of the DSP System Toolbox™ block with the same name. This page describes the block configuration and functionality available with a Simscape license. If you also have a DSP System Toolbox license, then the Spectrum Analyzer block in the Simscape > Utilities library is identical to the block in the DSP System Toolbox > Sinks library. For more information, see Spectrum Analyzer (DSP System Toolbox) in the DSP System Toolbox documentation.
The Spectrum Analyzer block accepts input signals with discrete sample times and displays frequency spectra of these signals.
To use a Spectrum Analyzer block, instead of a regular scope, in a Simscape model:
Add a Spectrum Analyzer block to your block diagram.
If your model uses a variable-step solver, also add a Rate Transition block and connect it to the input of the Spectrum Analyzer, setting the Output port sample time to the sample time you wish the Spectrum Analyzer to use.
If your model uses a local solver, then it produces output physical signals with discrete sample times and you do not need to add a Rate Transition block. However, if you need to down-sample from the solver fixed step size, you can also use a Rate Transition block. For more information on using local solvers, see Making Optimal Solver Choices for Physical Simulation.
Use a PS-Simulink Converter block to connect the output physical signal of interest to the input of the Spectrum Analyzer block (or to the input of the Rate Transition block, if using one). For more information, see Connecting Simscape Diagrams to Simulink Sources and Scopes. You can also use additional signal processing blocks between the PS-Simulink Converter and the Spectrum Analyzer to enhance signal quality.
Run the simulation. The Spectrum Analyzer, referred to here as the scope, opens and displays the frequency spectrum of the signal.
Note
To prevent the scope from opening when you run your model, right-click the scope icon and select Comment
Out
. If the scope is already open, and you comment it out in the model, the scope displays, "No data can be
shown because this scope is commented out." Select Uncomment
to turn the scope back on.
By default, Spectrum Analyzer updates the display at fixed intervals of time at a rate not exceeding 20 hertz. If you want Spectrum Analyzer to plot a spectrum on every simulation time step, you can disable the Reduce Plot Rate to Improve Performance option. In the Spectrum Analyzer menu, select Simulation > Reduce Plot Rate to Improve Performance to clear the check box. Tunable.
Note
When this check box is selected, Spectrum Analyzer may display a misleading spectrum in some situations. For example, if the input signal is wide-band with non-stationary behavior, such as a chirp signal, Spectrum Analyzer might display a stationary spectrum. The reason for this behavior is that Spectrum Analyzer buffers the input signal data and only updates the display periodically at approximately 20 times per second. Therefore, Spectrum Analyzer does not render changes to the spectrum that occur and elapse between updates, which gives the impression of an incorrect spectrum. To ensure that spectral estimates are as accurate as possible, clear the Reduce Plot Rate to Improve Performance check box. When you clear this box, Spectrum Analyzer calculates spectra whenever there is enough data, rendering results correctly.
This reference page describes the Spectrum Analyzer block available with Simscape or RF Blockset™. If you have DSP System Toolbox, more parameters and measurements are available. For information about the full Spectrum Analyzer, see Spectrum Analyzer (DSP System Toolbox).
SpectrumAnalyzerConfiguration
| dsp.SpectrumAnalyzer
(DSP System Toolbox) | Spectrum Analyzer (DSP System Toolbox)