Modelica.Math.FastFourierTransform.Examples

Examples demonstrating the usage of the Math.FastFourierTransform functions

Information

Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).

Package Content

Name Description
Modelica.Math.FastFourierTransform.Examples.RealFFT1 RealFFT1 Example demonstrating the use of an FFT calculation during simulation (and storing both amplitudes and phases on file)
Modelica.Math.FastFourierTransform.Examples.RealFFT2 RealFFT2 Example demonstrating the use of an FFT calculation during simulation (and storing only amplitudes on file)

Modelica.Math.FastFourierTransform.Examples.RealFFT1 Modelica.Math.FastFourierTransform.Examples.RealFFT1

Example demonstrating the use of an FFT calculation during simulation (and storing both amplitudes and phases on file)

Information

In this example the signal y

   y = 5 + 3*sin(2*pi*f1) + 1.5*cos(2*pi*f2)

is sampled and an FFT is computed from the sampled signal (default: f1 = 2 Hz, f2 = 3 Hz). In the public part the FFT is stored up to f_max (internally in the protected part the FFT is stored up to 5*f_max). With the default values for f_max (= 4 Hz) and f_resolution (= 0.2 Hz), the following results are achieved:

   fi[0]  = 0,  Ai[0]  = 5;   // mean value of signal
   fi[11] = 2,  Ai[11] = 3;   // frequency/amplitude of sine
   fi[16] = 3,  Ai[16] = 1.5; // frequency/amplitude of cosine

A plot of the resulting FFT is shown in the next image:

Note, phases of small amplitudes (= smaller as 0.0001*maximalAmplitude) are explicitly set to zero, since the corresponding "phase" is numerical noise (and would just be confusing). Furthermore, note that the FFT phases are with respect to a cos(..) signal.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Parameters

NameDescription
f_maxMaximum frequency of interest [Hz]
f_resolutionFrequency resolution [Hz]
f1Frequency of sine [Hz]
f2Frequency of cosine [Hz]
FFT_resultFileNameFile where FFT will be stored as [f,A,Phi], with f in {Hz] and A the amplitudes and Phi the phases in [rad]

Modelica.Math.FastFourierTransform.Examples.RealFFT2 Modelica.Math.FastFourierTransform.Examples.RealFFT2

Example demonstrating the use of an FFT calculation during simulation (and storing only amplitudes on file)

Information

This is the same example as Examples.RealFFT1 with the only difference that just the amplitudes of the FFT are stored on file (but not the phases).

Extends from Modelica.Icons.Example (Icon for runnable examples).

Parameters

NameDescription
f_maxMaximum frequency of interest [Hz]
f_resolutionFrequency resolution [Hz]
f1Frequency of sine [Hz]
f2Frequency of cosine [Hz]
FFT_resultFileNameFile where FFT will be stored as [f,A,Phi], with f in {Hz] and A the amplitues and Phi the phases in [rad]
Automatically generated Thu Dec 19 17:20:25 2019.