fftScaled impure function
Requirements.ChecksInFixedWindow_withFFT.Internal.fftScaled
· source
Compute scaled FFT
Extends Modelica.Icons.Function
Computes the amplitude spectrum of the samples u_buf (sample period Ts) with
Modelica.Math.FastFourierTransform.Internal.rawRealFFT and returns the amplitudes of the
first nf frequency points in A_buf; A_buf[1] is the mean value of
the samples. The mean value is removed from the samples before the FFT.
If the buffer is not completely filled (iTick < size(u_buf,1), e.g. because the simulation
ended), the stored samples are zero-padded, periods_ok is set to false and a message
with the required and the actual period is printed; otherwise periods_ok keeps the value
pre_periods_ok. The function asserts that the FFT succeeded. Called by
PartialFFT.
Revisions
| Date | Description |
|---|---|
| Nov. 29, 2015 | Initial version implemented by
Martin R. Kuhn and Martin Otter
(DLR Institute of System Dynamics and Control) The research leading to these results has received funding from the European Union’s Seventh Framework Programme (FP7/2007-2016) for the Clean Sky Joint Technology Initiative under grant agreement no. CSJU-GAM-SGO-2008-001. |
Inputs
| Name | Type | Description |
|---|---|---|
u_buf[…] input | Real | Signal for which FFT shall be computed; (size(u_buf,1) MUST be EVEN and should be an integer multiple of 2,3,5, that is size(u_buf,1) = 2^a*3^b*5^c, with a,b,c Integer >= 0) |
nf input | Integer | Number of frequency points that shall be returned in amplitudes and phases (typically: nf = max(1,min(integer(ceil(f_max/f_resolution))+1,nf_max))); the maximal possible value is nf_Max=div(size(u_buf,1),2)+1) |
iTick input | Integer | Number of sample points that have been stored in u_buf |
Ts input | SI.Time | Sample period of FFT |
pre_periods_ok input | Boolean | Previous value of periods_ok |
instanceName input | String | Instance name used in the warning message |
Outputs
| Name | Type | Description |
|---|---|---|
A_buf[…] output | Real | Amplitudes at the first nf frequency points (A_buf[1] = mean value of u) |
periods_ok output | Boolean | = false, if this or a previous FFT was computed from a partially filled buffer |