Main Content

spa

Estimate frequency response with fixed frequency resolution using spectral analysis

Description

example

G = spa(data) estimates the frequency response, along with uncertainty , and the noise spectrum from time- or frequency-domain data data. If data is a time series, spa(data) returns the output power spectrum along with uncertainty. spa computes the spectra at 128 equally spaced frequency values between 0 (excluded) and π, using a Hann window.

example

G = spa(data,winSize,freq) estimates the frequency response at the frequencies contained in freq, using a Hann window with size winSize.

G = spa(data,winSize,freq,maxSize) splits the input-output data into segments, each segment containing fewer than maxSize elements. Use this syntax to improve computational performance.

Examples

collapse all

Estimate frequency response with fixed resolution at 128 equally spaced, logarithmic frequency values between 0 (excluded) and π.

load iddata3; 
g = spa(z3); 
bode(g)

Figure contains 2 axes. Axes 1 with title From: u1 To: y1 contains an object of type line. This object represents g. Axes 2 contains an object of type line. This object represents g.

Define the frequency vector.

w = logspace(-2,pi,128);

Compute the frequency response.

load iddata3;
g = spa(z3,[],w);

[] specifies the default lag window size.

Plot the Bode response and disturbance spectrum with confidence interval of 3 standard deviations.

h = bodeplot(g);
showConfidence(h,3)

Figure contains 2 axes. Axes 1 with title From: u1 To: y1 contains an object of type line. This object represents g. Axes 2 contains an object of type line. This object represents g.

figure
h = spectrumplot(g);
showConfidence(h,3)

Figure contains an axes. The axes with title From: e@y1 To: y1 contains an object of type line. This object represents g.

Input Arguments

collapse all

Input-output data, specified as an iddata object or an idfrd object that can contain complex values. data can also contain time series data with only output.

Hann window size, also known as lag size, specified as a scalar integer. By default, the function sets the window size to min(length(data)/10,30).

Frequencies at which to estimate spectral response, specified as a row vector in units of rad/timeUnit, where timeUnit refers to the timeUnit property of data. By default, the function sets freq to a vector of 128 values in the range (0,π], evenly spaced logarithmically. For discrete-time models, set freq within the Nyquist frequency bound.

Maximum size of segments within data, specified as a positive integer. If you omit this argument, the function performs estimation using the full data set in data rather than segmenting the data.

Output Arguments

collapse all

Frequency response with uncertainty and noise spectrum, specified 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 Report property of the model. Report has the following fields.

Report FieldDescription
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:

FieldDescription
Name

Name of the data set.

Type

Data type.

Length

Number of data samples.

Ts

Sample time. This is equivalent to Data.Ts.

InterSample

Input intersample behavior. One of the following values:

  • 'zoh' — Zero-order hold maintains a piecewise-constant input signal between samples.

  • 'foh' — First-order hold maintains a piecewise-linear input signal between samples.

  • 'bl' — Band-limited behavior specifies that the continuous-time input signal has zero power above the Nyquist frequency.

The value of Intersample has no effect on estimation results for discrete-time models.

InputOffset

Offset removed from time-domain input data during estimation.

OutputOffset

Offset removed from time-domain output data during estimation.

More About

collapse all

Frequency Response Function

A Frequency response function describes the steady-state response of a system to sinusoidal inputs. For a linear system, a sinusoidal input of a specific frequency results in an output that is also a sinusoid with the same frequency, but with a different amplitude and phase. The frequency response function describes the amplitude change and phase shift as a function of frequency.

To better understand the frequency response function, consider the following description of a linear dynamic system:

y(t)=G(q)u(t)+v(t)

Here u(t) and y(t) are the input and output signals, respectively. G(q) is called the transfer function of the system—it captures the system dynamics that take the input to the output. The notation G(q)u(t) represents the following operation:

G(q)u(t)=k=1g(k)u(tk)

q is the shift operator, defined by the following equation:

G(q)=k=1g(k)qk      q1u(t)=u(t1)

G(q) is the frequency-response function, which is evaluated on the unit circle, G(q=e).

Together, G(q=e) and the output noise spectrum Φ^v(ω) are the frequency-domain description of the system.

The frequency-response function estimated using the Blackman-Tukey approach is given by the following equation:

G^N(eiω)=Φ^yu(ω)Φ^u(ω)

In this case, ^ represents approximate quantities. For a derivation of this equation, see the chapter on nonparametric time- and frequency-domain methods in [1].

Output Noise Spectrum

The output noise spectrum (spectrum of v(t)) is given by the following equation:

Φ^v(ω)=Φ^y(ω)|Φ^yu(ω)|2Φ^u(ω)

This equation for the noise spectrum is derived by assuming that the linear relationship y(t)=G(q)u(t)+v(t), that u(t) is independent of v(t), and that the following relationships between the spectra:

Φy(ω)=|G(eiω)|2Φu(ω)+Φv(ω)

Φyu(ω)=G(eiω)Φu(ω)

Here, the noise spectrum is given by the following equation:

Φv(ω)τ=Rv(τ)eiwτ

Φ^yu(ω) is the output-input cross-spectrum and Φ^u(ω) is the input spectrum.

Alternatively, the disturbance v(t) can be described as filtered white noise:

v(t)=H(q)e(t)

Here, e(t) is the white noise with variance λ and the noise power spectrum is given by the following equation:

Φv(ω)=λ|H(eiω)|2

Algorithms

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

  1. Compute the covariances and cross-covariance from u(t) and y(t):

    R^y(τ)=1Nt=1Ny(t+τ)y(t)R^u(τ)=1Nt=1Nu(t+τ)u(t)R^yu(τ)=1Nt=1Ny(t+τ)u(t)

  2. Compute the Fourier transforms of the covariances and the cross-covariance:

    Φ^y(ω)=τ=MMR^y(τ)WM(τ)eiωτΦ^u(ω)=τ=MMR^u(τ)WM(τ)eiωτΦ^yu(ω)=τ=MMR^yu(τ)WM(τ)eiωτ

    where WM(τ) 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, the operation uses fast Fourier transforms (FFT), which is more efficient than for user-defined frequencies.

    Note

    M =γ is in Table 6.1 of [1]. Standard deviations are on pages 184 and 188 in [1].

  3. Compute the frequency-response function G^N(eiω) and the output noise spectrum Φ^v(ω).

    G^N(eiω)=Φ^yu(ω)Φ^u(ω)

    Φv(ω)τ=Rv(τ)eiwτ

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=m=MMEz(t+m)z(t)WM(Ts)exp(iωm)

' is a complex-conjugate transpose.

References

[1] Ljung, Lennart. System Identification: Theory for the User, Second Ed., Prentice Hall PTR, 1999.

Introduced before R2006a