> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/smart-power-simulation-software-sps/blocks-functions-tools/control-and-measurements/analysis/fourier.md).

# Fourier

## Description

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-97de62713a5def6599fb288f6c847c932b9b56ba%2Ffourier_block.png?alt=media" alt=""><figcaption></figcaption></figure>

The **Fourier** block, located in the **OPAL-RT SPS Software/Sensors and Measurements** library, performs a Fourier analysis of the input signal over a running window of one cycle of the fundamental frequency of the signal.

The Fourier block can be programmed to calculate the magnitude and phase of the DC component, the fundamental, or any harmonic component of the input signal.

Recall that a signal *f*(*t*) can be expressed by a Fourier series of the form

$$
f(t)
====

\frac{a\_0}{2}
\+
\sum\_{n=1}^{\infty}
\left(
a\_n \cos(n \omega t)
\+
b\_n \sin(n \omega t)
\right)
\\\[8pt]
$$

where *n* represents the rank of the harmonics. (*n* = 1 corresponds to the fundamental component.) The magnitude and phase of the selected harmonic component are calculated by these equations:

$$
|H\_n|
======

\sqrt{a\_n^{2} + b\_n^{2}}
\\\[8pt]

# \angle H\_n

\arctan \left(\frac{a\_n}{b\_n}\right)
\\\[8pt]
$$

where

$$
a\_n
====

\frac{2}{T}
\int\_{t-T}^{t}
f(t), \cos(n \omega t), dt
\\\[8pt]

# b\_n

\frac{2}{T}
\int\_{t-T}^{t}
f(t), \sin(n \omega t), dt
\\\[8pt]

T = \frac{1}{f\_1}
\\\[8pt]

f\_1 : \text{Fundamental frequency}
\\\[8pt]
$$

As this block uses a running average window, one cycle of simulation must complete before the outputs give the correct magnitude and angle. For the first cycle of simulation,

the outputs are held to the values specified by the initial input parameter.

#### Characteristics

<table data-header-hidden><thead><tr><th width="250.0888671875"></th><th></th></tr></thead><tbody><tr><td>Sample Time</td><td>Specified in the <strong>Sample Time</strong> parameter. Continuous if <strong>Sample Time</strong> = 0.</td></tr><tr><td>Scalar Expansion</td><td>Yes, of the parameters.</td></tr><tr><td>Dimensionalized</td><td>Yes.</td></tr></tbody></table>

## Ports

### Input

<table data-header-hidden><thead><tr><th width="249.77777099609375"></th><th></th></tr></thead><tbody><tr><td><strong>Input</strong> — Signal to analyze<br>scalar | vector</td><td><p>Signal to analyze.</p><p>Typical input signals are voltages or currents measured by Current Measurement or Voltage Measurement blocks.</p></td></tr></tbody></table>

### Output

<table data-header-hidden><thead><tr><th width="249.99993896484375"></th><th></th></tr></thead><tbody><tr><td><strong>|u|</strong> — Magnitude of specified harmonic component<br>scalar</td><td>Magnitude of the specified harmonic component, in the same units as the input signal.</td></tr><tr><td><strong>∠u</strong> — Phase of specified harmonic component<br>scalar</td><td>Phase, in degrees, of the specified harmonic component.</td></tr></tbody></table>

## Parameters

To edit block parameters interactively, use the Property Inspector. From the Simulink<sup>®</sup> Toolstrip, on the **Simulation** tab, in the **Prepare** gallery, select **Property Inspector**.

<table data-header-hidden><thead><tr><th width="250.00006103515625"></th><th></th></tr></thead><tbody><tr><td><strong>Fundamental frequency (Hz)</strong> — Frequency of fundamental signal<br>60 (default) | scalar</td><td>Fundamental frequency, in hertz, of the input signal.</td></tr><tr><td><strong>Harmonic n (0 = DC, 1 = fundamental)</strong> — Harmonic component for Fourier analysis<br>1 (default) | nonnegative scalar</td><td><p>Harmonic component for the Fourier analysis. Enter 0 to analyze the DC component.</p><p>Enter 1 to analyze the fundamental frequency, or enter a number corresponding to the desired harmonic.</p></td></tr><tr><td><strong>Initial input [ Mag, Phase (degrees) ]</strong> — Initial magnitude and phase of output signal<br>[0, 0] (default) | scalar</td><td>Initial magnitude and phase in degrees of the output signal.</td></tr><tr><td><strong>Sample time</strong> — Block sample time<br>0 (default) | nonnegative scalar</td><td>Sample time of the block, in seconds. Set to 0 to implement a continuous block.</td></tr></tbody></table>

## Examples

The power\_Fourier model shows two applications of the Fourier measurement block.

The upper part of the model shows how to use the Fourier block to compute the DC component, fundamental value, and second and third harmonic content of the same input signal. In the lower part of the model, the block computes the fundamental value (magnitude and phase) of three different inputs.

For this application, specify initial values for the three output signals in the dialog box of the mask.

The model sample time is parameterized by the Ts variable set to a default value of 50e-6 s. Set Ts to 0 in the command window to simulate the model in continuous mode.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/smart-power-simulation-software-sps/blocks-functions-tools/control-and-measurements/analysis/fourier.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
