When you want to transform time-domain data into the frequency domain, use the FFT block.
In this example, you use the Sine Wave block to generate two sinusoids, one at 15 Hz and the other at 40 Hz. You sum the sinusoids point-by-point to generate the compound sinusoid
At the MATLAB® command prompt, type
The FFT Example opens.
Double-click the Sine Wave block. The Block Parameters: Sine Wave dialog box opens.
Set the block parameters as follows:
Phase offset =
Sample time =
Samples per frame =
Based on these parameters, the Sine Wave block outputs two sinusoidal signals with identical amplitudes, phases, and sample times. One sinusoid oscillates at 15 Hz and the other at 40 Hz.
Save these parameters and close the dialog box by clicking OK.
Double-click the Matrix Sum block. The Block Parameters: Matrix Sum dialog box opens.
Set the Sum over parameter
Specified dimension and the Dimension parameter
2. Click OK to save
Because each column represents a different signal, you need to sum along the individual rows in order to add the values of the sinusoids at each time step.
Double-click the Complex to Magnitude-Angle block. The Block Parameters: Complex to Magnitude-Angle dialog box opens.
Set the Output parameter
Magnitude, and then click OK.
This block takes the complex output of the FFT block and converts this output to magnitude.
Double-click the Vector Scope block.
Set the block parameters as follows, and then click OK:
Click the Scope Properties tab.
Input domain =
Click the Axis Properties tab.
Frequency units =
corresponds to the units of the input signals.)
Frequency range =
Select the Inherit sample time from input check box.
Amplitude scaling =
Run the model.
The scope shows the two peaks at 15 and 40 Hz, as expected.
You have now transformed two sinusoidal signals from the time domain to the frequency domain.
Note that the sequence of FFT, Complex to Magnitude-Angle, and Vector Scope blocks could be replaced by a single Spectrum Analyzer block, which computes the magnitude FFT internally. Other blocks that compute the FFT internally are the blocks in the Power Spectrum Estimation library. See Estimate the Power Spectrum in Simulinkfor more information about these blocks.