blockRealFFT

Sampling and FFT of input u

Extends from Modelica.Blocks.Interfaces.DiscreteBlock (Base class of discrete control blocks).

Information

This block samples the input signal, calculates the Fast Fourier Transform by function Math.realFFT, and (when simulation terminates) writes the output to result file resultFileName by function Math.realFFTwriteToFile.

The number of sampling points as well as the samplePeriod is calculated from desired maximum frequency f_max and frequency resolution f_res.

Note

The user has to take care that enough points can be sampled before the simulation ends: startTime + (ns - 1)*samplePeriod <= stopTime.

The result file is written as mat, first column = frequency, second column = amplitudes, third column = phases. The frequency points are separated by rows with amplitude and phase = 0, so one can plot the result directly as frequency lines.

Parameters

TypeNameDefaultDescription
SI.TimesamplePeriod (from DiscreteBlock)Sample period of component
SI.TimestartTime (from DiscreteBlock)0First sample time instant
SI.Frequencyf_maxMaximum frequency of interest
SI.Frequencyf_resFrequency resolution
IntegernsModelica.Math.FastFourierTransform.realFFTsamplePoints(f_max, f_res, f_max_factor = 5)Number of samples
Integernfmax(1, min(integer(ceil(f_max/f_res)) + 1, div(ns, 2)))Number of frequency points
StringresultFileName"realFFT.mat"Result file: f, abs, arg

Connectors

TypeNameDefaultDescription
Modelica.Blocks.Interfaces.RealInputu

Components

TypeNameDefaultDescription
IntegerinfoInformation flag from FFT computation