FRD
A Frequency Response Data (FRD) model stores the measured or simulated frequency response of a system directly as complex numbers at specific frequencies.
Rather than representing an idealized mathematical model (like state-space or transfer functions), FRD models capture the actual empirical magnitude and phase behavior of a system across a defined frequency vector (\omega).
Excel Usage
=FRD(frdata, omega)
frdata(list[list], required): Complex vector with the system response.omega(list[list], required): Vector of frequencies (in rad/s) at which the response was evaluated or measured.
Returns (str): String representation of the FRD model.
Example 1: Simple magnitude response
Inputs:
| frdata | omega | ||||
|---|---|---|---|---|---|
| 1 | 1 | 0.5 | 1 | 10 | 100 |
Excel formula:
=FRD({1,1,0.5}, {1,10,100})
Expected output:
"<FrequencyResponseData>: sys[0]\nInputs (1): ['u[0]']\nOutputs (1): ['y[0]']\n\nFreq [rad/s] Response\n------------ ---------------------\n 1.000 1 +0j\n 10.000 1 +0j\n 100.000 0.5 +0j"
Example 2: Synthetic complex frequency response
Inputs:
| frdata | omega | ||||
|---|---|---|---|---|---|
| 1 | 0.5 | 0.1 | 0.1 | 1 | 10 |
Excel formula:
=FRD({1,0.5,0.1}, {0.1,1,10})
Expected output:
"<FrequencyResponseData>: sys[1]\nInputs (1): ['u[0]']\nOutputs (1): ['y[0]']\n\nFreq [rad/s] Response\n------------ ---------------------\n 0.100 1 +0j\n 1.000 0.5 +0j\n 10.000 0.1 +0j"
Example 3: Single frequency point
Inputs:
| frdata | omega |
|---|---|
| 0.866 | 50 |
Excel formula:
=FRD({0.866}, {50})
Expected output:
"<FrequencyResponseData>: sys[2]\nInputs (1): ['u[0]']\nOutputs (1): ['y[0]']\n\nFreq [rad/s] Response\n------------ ---------------------\n 50.000 0.866 +0j"
Example 4: Simulating a low pass filter roll off
Inputs:
| frdata | omega | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| 1 | 0.99 | 0.707 | 0.1 | 0.01 | 0.1 | 1 | 10 | 100 | 1000 |
Excel formula:
=FRD({1,0.99,0.707,0.1,0.01}, {0.1,1,10,100,1000})
Expected output:
"<FrequencyResponseData>: sys[3]\nInputs (1): ['u[0]']\nOutputs (1): ['y[0]']\n\nFreq [rad/s] Response\n------------ ---------------------\n 0.100 1 +0j\n 1.000 0.99 +0j\n 10.000 0.707 +0j\n 100.000 0.1 +0j\n 1000.000 0.01 +0j"
Python Code
Show Code
import control as ct
import numpy as np
def frd(frdata, omega):
"""
Create a frequency response data (FRD) model from measured response data.
See: https://python-control.readthedocs.io/en/latest/generated/control.frd.html
This example function is provided as-is without any representation of accuracy.
Args:
frdata (list[list]): Complex vector with the system response.
omega (list[list]): Vector of frequencies (in rad/s) at which the response was evaluated or measured.
Returns:
str: String representation of the FRD model.
"""
try:
def flatten_to_1d(x):
if not isinstance(x, list):
return [x] if str(x) != "" else []
flat = []
for row in x:
if isinstance(row, list):
for val in row:
if str(val) != "":
flat.append(complex(val) if isinstance(val, (complex, str)) else float(val))
elif str(row) != "":
flat.append(complex(row) if isinstance(row, (complex, str)) else float(row))
return flat
response = flatten_to_1d(frdata)
freqs = flatten_to_1d(omega)
if len(response) != len(freqs):
return "Error: Response data and frequency data must have the same length"
if len(freqs) == 0:
return "Error: Data vectors cannot be empty"
sys = ct.frd(response, freqs)
return str(sys)
except Exception as e:
return f"Error: {str(e)}"