Estimate frequency response with fixed frequency resolution using spectral analysis
estimates the frequency response, along with
and the noise spectrum from time- or frequency-domain data
G = spa(
data is a time series,
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
Estimate Frequency Response
Estimate the frequency response for the input/output data in the
z3. Use the default fixed resolution of 128 equally spaced logarithmic frequency values between 0 (excluded) and .
load iddata3 z3; g = spa(z3); bode(g)
Estimate Frequency Response at Specified Frequencies
Generate the logarithmically spaced vector
f = logspace(-2,pi,128);
Estimate the frequency response for the input/output data
z3. Specify the window size as
 to obtain the default lag window size.
load iddata3 z3; g = spa(z3,,f);
Plot the Bode response and disturbance spectrum with a confidence interval of 3 standard deviations.
h = bodeplot(g); showConfidence(h,3)
figure h = spectrumplot(g); showConfidence(h,3)
winSize — Window size
 (default) | scalar integer
Hann window size, also known as lag size, specified as a scalar integer.
By default, the function sets the window size to
freq — Frequencies
Frequencies at which to estimate spectral response, specified as a row
vector in units of rad/
TimeUnit refers to the
TimeUnit property of
default, the function sets
freq to a vector of 128
values in the range (0,π], evenly spaced logarithmically. For discrete-time
freq within the Nyquist frequency bound.
maxSize — Maximum segment size
250e3 (default) | positive integer
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.
G — Frequency response and noise spectrum
Frequency response with uncertainty and noise spectrum, specified as an
idfrd object. For time series
G is the estimated spectrum and standard
Information about the estimation results and options used is stored in the
Report property of the model.
Report has the following fields.
Summary of the model status, which indicates whether the model was created by construction or obtained by estimation.
Estimation command used.
Size of the Hann window.
Attributes of the data used for estimation. Structure with the following fields.
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:
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:
q is the shift operator, defined by the following equation:
G(q) is the frequency-response function when it is evaluated on the unit circle, G(q=eiω).
Together, G(q=eiω) and the output noise spectrum compose the frequency-domain description of the system.
The frequency-response function estimated using the Blackman-Tukey approach is given by the following equation:
In this case, ^ represents approximate quantities. For a derivation of this equation, see the chapter on nonparametric time- and frequency-domain methods in .
Output Noise Spectrum
The output noise spectrum (spectrum of v(t)) is given by the following equation:
This equation for the noise spectrum is derived by assuming that the linear relationship holds, that u(t) is independent of v(t), and that the following relationships between the spectra hold:
Here, the noise spectrum is given by the following equation:
is the output-input cross-spectrum and is the input spectrum.
Alternatively, the disturbance v(t) can be described as filtered white noise:
Here, e(t) is the white noise with variance and the noise power spectrum is given by the following equation:
spa applies the Blackman-Tukey spectral analysis method by
following these steps:
Compute the covariances and cross-covariance from u(t) and y(t):
Compute the Fourier transforms of the covariances and the cross-covariance:
where 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 to 2π/M rad/sample time.
By default, this operation uses 128 equally spaced frequency values between 0 (excluded) and π, where
Tsis 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 are more efficient than for user-defined frequencies.
Compute the frequency-response function and the output noise spectrum .
spectrum is the spectrum matrix for both the output and the input
channels. That is, if
z = [data.OutputData,
spectrum contains as spectrum
data the matrix-valued power spectrum of
' is a complex-conjugate transpose.
 Ljung, Lennart. System Identification: Theory for the User. 2nd ed. Prentice Hall Information and System Sciences Series. Upper Saddle River, NJ: Prentice Hall PTR, 1999.
Introduced before R2006a