Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

## Transform Time-Domain Data into Frequency Domain

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

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

1. At the MATLAB® command prompt, type ex_fft_tutex_fft_tut.

The FFT Example opens.

2. Double-click the Sine Wave block. The Block Parameters: Sine Wave dialog box opens.

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

4. Save these parameters and close the dialog box by clicking OK.

5. Double-click the Matrix Sum block. The Block Parameters: Matrix Sum dialog box opens.

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

7. Double-click the Complex to Magnitude-Angle block. The Block Parameters: Complex to Magnitude-Angle dialog box opens.

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

9. Double-click the Vector Scope block.

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

11. 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 Spectral Analysis for more information about these blocks.