Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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

$$u=\mathrm{sin}\left(30\pi t\right)+\mathrm{sin}\left(80\pi t\right)$$

Then, you transform this sinusoid into the frequency domain using an FFT block:

At the MATLAB

^{®}command prompt, type`ex_fft_tut`

.The FFT Example opens.

Double-click the Sine Wave block. The

**Block Parameters: Sine Wave**dialog box opens.Set the block parameters as follows:

**Amplitude**=`1`

**Frequency**=`[15 40]`

**Phase offset**=`0`

**Sample time**=`0.001`

**Samples per frame**=`128`

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 to`Specified dimension`

and the**Dimension**parameter to`2`

. Click**OK**to save your changes.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 to`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**=`Frequency`

Click the

**Axis Properties**tab.**Frequency units**=`Hertz`

(This corresponds to the units of the input signals.)**Frequency range**=`[0...Fs/2]`

Select the

**Inherit sample time from input**check box.**Amplitude scaling**=`Magnitude`

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 Spectral Density in Simulinkfor more information about these blocks.

Was this topic helpful?