Estimate frequency response with fixed frequency resolution using spectral analysis

`G = spa(data)`

G = spa(data,winSize,freq)

G = spa(data,winSize,freq,MaxSize)

`G = spa(data)`

estimates frequency response
(with uncertainty) and noise spectrum from time- or frequency-domain
data. `data`

is an `iddata`

or `idfrd`

object
and can be complex valued. `G`

is as an `idfrd`

object.
For time-series `data`

, `G`

is the
estimated spectrum and standard deviation.

Information about the estimation results and options used is
stored in the model's `Report`

property. `Report`

has
the following fields:

`Status`

— Summary of the model status, which indicates whether the model was created by construction or obtained by estimation.`Method`

— Estimation command used.`WindowSize`

— Size of the Hann window.`DataUsed`

— Attributes of the data used for estimation. Structure with the following fields:`Name`

— Name of the data set.`Type`

— Data type.`Length`

— Number of data samples.`Ts`

— Sample time.`InterSample`

— Input intersample behavior.`InputOffset`

— Offset removed from time-domain input data during estimation.`OutputOffset`

— Offset removed from time-domain output data during estimation.

`G = spa(data,winSize,freq)`

estimates frequency response at frequencies
`freq`

. `freq`

is a row vector of values in
rad/`TimeUnit`

, where `TimeUnit`

refers to the
`TimeUnit`

property of data. For discrete-time data, set
`freq`

within the Nyquist frequency bound.
`winSize`

is a scalar integer that sets the size of the Hann
window.

`G = spa(data,winSize,freq,MaxSize)`

can
improve computational performance using `MaxSize`

to
split the input-output data such that each segment contains fewer
than `MaxSize`

elements. `MaxSize`

is
a positive integer.

`spa`

applies the Blackman-Tukey spectral
analysis method by following these steps:

Computes the covariances and cross-covariance from

*u(t)*and*y(t)*:$$\begin{array}{l}{\widehat{R}}_{y}\left(\tau \right)={\scriptscriptstyle \frac{1}{N}}{\displaystyle \sum _{t=1}^{N}y\left(t+\tau \right)y\left(t\right)}\\ {\widehat{R}}_{u}\left(\tau \right)={\scriptscriptstyle \frac{1}{N}}{\displaystyle \sum _{t=1}^{N}u\left(t+\tau \right)u\left(t\right)}\\ {\widehat{R}}_{yu}\left(\tau \right)={\scriptscriptstyle \frac{1}{N}}{\displaystyle \sum _{t=1}^{N}y\left(t+\tau \right)u\left(t\right)}\end{array}$$

Computes the Fourier transforms of the covariances and the cross-covariance:

$$\begin{array}{l}{\widehat{\Phi}}_{y}(\omega )={\displaystyle \sum _{\tau =-M}^{M}{\widehat{R}}_{y}}(\tau ){W}_{M}(\tau ){e}^{-i\omega \tau}\\ {\widehat{\Phi}}_{u}(\omega )={\displaystyle \sum _{\tau =-M}^{M}{\widehat{R}}_{u}}(\tau ){W}_{M}(\tau ){e}^{-i\omega \tau}\\ {\widehat{\Phi}}_{yu}(\omega )={\displaystyle \sum _{\tau =-M}^{M}{\widehat{R}}_{yu}}(\tau ){W}_{M}(\tau ){e}^{-i\omega \tau}\end{array}$$

where $${W}_{M}(\tau )$$ is the Hann window with a width (lag size) of

*M*. You can specify`M`

to control the frequency resolution of the estimate, which is approximately equal 2π/`M`

rad/sample time.By default, this operation uses 128 equally spaced frequency values between 0 (excluded) and π, where

`w = [1:128]/128*pi/Ts`

and`Ts`

is the sample time of that data set. The default lag size of the Hann window is`M = min(length(data)/10,30)`

. For default frequencies, uses fast Fourier transforms (FFT)—which is more efficient than for user-defined frequencies.### Note

`M =`

γ is in Table 6.1 of Ljung (1999). Standard deviations are on pages 184 and 188 in Ljung (1999).Compute the frequency-response function $${\widehat{G}}_{N}\left({e}^{i\omega}\right)$$ and the output noise spectrum $${\widehat{\Phi}}_{v}(\omega )$$.

$${\widehat{G}}_{N}\left({e}^{i\omega}\right)=\frac{{\widehat{\Phi}}_{yu}\left(\omega \right)}{{\widehat{\Phi}}_{u}\left(\omega \right)}$$

$${\Phi}_{v}(\omega )\equiv {\displaystyle \sum _{\tau =-\infty}^{\infty}{R}_{v}}(\tau ){e}^{-iw\tau}$$

`spectrum`

is the spectrum matrix for both
the output and the input channels. That is, if `z = [data.OutputData`

, `data.InputData]`

, `spectrum`

contains
as spectrum data the matrix-valued power spectrum of `z`

.

$$S={\displaystyle \sum _{m=-M}^{M}Ez\left(t+m\right)z}{\left(t\right)}^{\prime}{W}_{M}\left({T}_{s}\right)\mathrm{exp}\left(-i\omega m\right)$$

`'`

is a complex-conjugate transpose.

Ljung, L. *System Identification: Theory for the User*,
Second Ed., Prentice Hall PTR, 1999.