You can use DSP System Toolbox™ blocks to work with signals in both the time and frequency domain. To display frequency-domain signals, you can use blocks from the Sinks library, such as the Vector Scope, Spectrum Analyzer, Matrix Viewer, and Waterfall Scope blocks.
With the Spectrum Analyzer block, you can display the frequency spectra of time-domain input data. In contrast to the Vector Scope block, the Spectrum Analyzer block computes the Fast Fourier Transform (FFT) of the input signal internally, transforming the signal into the frequency domain.
This example shows how you can use a Spectrum Analyzer block to display the frequency content of two frame-based signals simultaneously:
The Spectrum Analyzer example opens, and the variables, Fs and mtlb, are loaded into the MATLAB workspace.
Signal = mtlb
Sample time = 1
Samples per frame = 16
Form output after final data value = Cyclic Repetition
Based on these parameters, the Signal From Workspace block repeatedly outputs the input signal, mtlb, as a frame-based signal with a sample period of 1 second.
Number of inputs = 2
Mode = Multidimensional array
Concatenate dimension = 2
The Matrix Concatenate block combines the two signals so that each column corresponds to a different signal.
Expand the Main options pane, if it is not already expanded.
Set Type to Power.
Select the Full frequency span check box.
Set RBW (Hz) to 5.91e-3.
Expand the Trace options pane, if it is not already expanded.
Set Units to dBW.
Set Averages to 2.
Expand the Window options pane, if it is not already expanded.
Set Overlap (%) to 50.
Set Window to Hann.
Based on these parameters, the Spectrum Analyzer uses 128 samples from each input channel to calculate a new windowed data segment, as shown in the following equation.
There are also 128 frequency points in the FFT. Also, because Overlap (%) is set to 50, there is a buffer overlap length of 64 samples in each spectral estimate, as shown in the following equation.
Every time the scope updates the display, 64 points are plotted for each channel. At 16 samples per frame, Spectrum Analyzer waits for 3 frames or 48 samples before displaying the first power spectral estimate.
The power spectrum of the first input signal, from column one, is the yellow line. The power spectrum of the second input signal, from column two, is the blue line.