functionrealFFTwriteToFile

Write real FFT computation to file

Extends from Modelica.Icons.Function (Icon for functions).

Information

Syntax

success = realFFTwriteToFile(t_computed, fileName, f_max, amplitudes, phases, format);

Description

This functions stores the result of an FFT computation on file, so that it can be easily plotted. amplitudes and phases are the vectors that hold the amplitudes and phases values of an FFT computation. If the size of the phases vector is zero, no phases will be stored on file. Otherwise, phases must have the same dimension as the amplitudes vector. The frequency vector f is constructed within the function from the dimension of the amplitudes vector and the information that amplitudes[end] is at frequency f_max. The format argument defines the file format (for details see writeRealMatrix). Argument t_computed is the actual time instant when the FFT was computed. It is used in the print message after the result was stored on file.

The matrix on file has the following structure:

  • First column: Equidistant frequency vector f in Hz from 0 Hz ... f_max Hz.
  • Second column: Amplitudes[:]
  • Optional third column: Phases[:]

Example

See detailed example model: Examples.RealFFT1.

See also

realFFTinfo, realFFTsamplePoints, realFFT

Inputs

TypeNameDefaultDescription
Realt_computedTime instant at which the FFT was computed
StringfileNameFile where FFT shall be stored (if it exists, it is deleted and then re-created)
SI.Frequencyf_maxMaximum frequency
Real[:]amplitudesAmplitudes of FFT
Real[:]phasesfill(0.0, 0)Phases of FFT (either provide no argument, or a vector with the same length as amplitudes)
Stringformat"4"MATLAB MAT-file version: "4" -> v4, "6" -> v6, "7" -> v7

Outputs

TypeNameDefaultDescription
Booleansuccess= true, if successful