blockRealFFT
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
| Type | Name | Default | Description |
|---|---|---|---|
| SI.Time | samplePeriod (from DiscreteBlock) | Sample period of component | |
| SI.Time | startTime (from DiscreteBlock) | 0 | First sample time instant |
| SI.Frequency | f_max | Maximum frequency of interest | |
| SI.Frequency | f_res | Frequency resolution | |
| Integer | ns | Modelica.Math.FastFourierTransform.realFFTsamplePoints(f_max, f_res, f_max_factor = 5) | Number of samples |
| Integer | nf | max(1, min(integer(ceil(f_max/f_res)) + 1, div(ns, 2))) | Number of frequency points |
| String | resultFileName | "realFFT.mat" | Result file: f, abs, arg |
Connectors
| Type | Name | Default | Description |
|---|---|---|---|
| Modelica.Blocks.Interfaces.RealInput | u |
Components
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | info | Information flag from FFT computation |