The System Identification Toolbox™ software lets you use frequencydomain data to identify linear models at the command line and in the System Identification app. You can estimate both continuoustime and discretetime linear models using frequencydomain data. This topic presents an overview of model estimation in the toolbox using frequencydomain data. For an example of model estimation using frequencydomain data, see Frequency Domain Identification: Estimating Models Using Frequency Domain Data.
Frequencydomain data can be of two types:
Frequency domain inputoutput data —
You obtain the data by computing Fourier transforms of timedomain
input, u(t), and output, y(t),
signals. The data is the set of input, U(ω),
and output, Y(ω), signals
in frequency domain. In the toolbox, frequencydomain inputoutput
data is represented using iddata
objects.
For more information, see Representing FrequencyDomain Data in the Toolbox.
Frequencyresponse data —
Also called frequency function or frequencyresponse function (FRF),
the data consists of transfer function measurements, G(iω),
of a system at a discrete set of frequencies ω.
Frequencyresponse data at a frequency ω tells
you how a linear system responds to a sinusoidal input of the same
frequency. In the toolbox, frequencyresponse data is represented
using idfrd
objects. For more
information, see Representing FrequencyDomain Data in the Toolbox. You can
obtain frequencyresponse data in the following ways:
Measure the frequencyresponse data values directly, such as by using a spectrum analyzer.
Perform spectral analysis of timedomain or frequencydomain
inputoutput data (iddata
objects) using commands
such as spa
and spafdr
.
Compute the frequencyresponse of an identified linear
model using commands such as freqresp
, bode
, and idfrd
.
The workflow for model estimation using frequencydomain data is the same as that for estimation using timedomain data. If needed, you first prepare the data for model identification by removing outliers and filtering the data. You then estimate a linear parametric model from the data, and validate the estimation.
Using frequencydomain data has the following advantages:
Data compression — You can compress long records of data when you convert timedomain data to frequency domain. For example, you can use logarithmically spaced frequencies.
Non uniformity — Frequencydomain data does not have to be uniformly spaced. Your data can have frequencydependent resolution so that more data points are used in the frequency regions of interest. For example, the frequencies of interest could be the bandwidth range of a system, or near the resonances of a system.
Prefiltering — Prefiltering of data in the frequencydomain becomes simple. It corresponds to assigning different weights to different frequencies of the data.
Continuoustime signal  You can represent continuoustime signals using frequencydomain data and use the data for estimation.
Before performing model estimation, you specify the frequencydomain data as objects in the toolbox. You can specify both continuoustime and discretetime frequencydomain data.
Frequency domain inputoutput
data — Specify as an iddata
object.
In the object, you store U(ω), Y(ω),
and frequency vector ω. The Domain
property
of the object is 'Frequency'
, to specify that the
object contains frequencydomain signals. If U(ω), Y(ω)
are discretetime Fourier transforms of discretetime signals, sampled
with sampling interval Ts
, denote the sampling
interval in the iddata
object. If U(ω), Y(ω)
are Fourier transforms of continuoustime signals, specify Ts
as 0
in
the iddata
object.
To plot the data at the command line, use the plot
command.
For example, you can plot the phase and magnitude of frequencydomain inputoutput data.
Load timedomain inputoutput data.
load iddata1 z1
The timedomain inputs u
and outputs y
are stored in z1
, an iddata
object whose Domain
property is set to 'Time'
.
Fouriertransform the data to obtain frequencydomain inputoutput data.
zf = fft(z1);
The Domain
property of zf
is set to 'Frequency'
, indicating that it is frequencydomain data.
Plot the magnitude and phase of the frequencydomain inputoutput data.
plot(zf)
Frequencyresponse data —
Specify as an idfrd
object.
If you have Control System
Toolbox™ software, you can also specify
the data as an frd
object.
To plot the data at the command line, use the bode
command.
For example, you can plot the frequencyresponse of a transfer function model.
Create a transfer function model of your system.
sys = tf([1 0.2],[1 2 1 1]);
Calculate the frequencyresponse of the transfer function model, sys
, at 100 frequency points. Specify the range of the frequencies as 0.1 rad/s to 10 rad/s.
freq = logspace(1,1,100); frdModel = idfrd(sys,freq);
Plot the frequencyresponse of the model.
bode(frdModel)
For more information about the frequencydomain data types and how to specify them, see FrequencyDomain Data Representation.
You can also transform between frequencydomain and timedomain data types using the following commands.
Original Data Format  To TimeDomain Data ( iddata object)  To FrequencyDomain Data ( iddata object)  To FrequencyResponse Data ( idfrd object) 

TimeDomain Data ( iddata object)  N/A  Use fft  
FrequencyDomain Data ( iddata object)  Use ifft (works only
for evenly spaced frequencydomain data).  N/A  
FrequencyResponse Data ( idfrd object)  Not supported  Use iddata . The software
creates a frequencydomain iddata object that
has the same ratio between output and input as the original idfrd object
frequencyresponse data. 

For more information about transforming between data types in the app or at the command line, see the Transform Data category page.
Unlike timedomain data, the sample time Ts
of
frequencydomain data can be zero. Frequencydomain data with zero Ts
is
called continuoustime data. Frequencydomain data with Ts
greater
than zero is called discretetime data.
You can obtain continuoustime frequencydomain data
(Ts
= 0) in the following ways:
Generate the data from known continuoustime analytical expressions.
For example, suppose that you know the frequencyresponse of your system is $$G(\omega )=1/(b+j\omega )$$, where b is a constant. Also assume that the timedomain inputs to your system are, $$u(t)={e}^{at}\mathrm{sin}{w}_{0}t$$, where a is a constant greater than zero, and u(t) is zero for all times t less than zero. You can compute the Fourier transform of u(t) to obtain
$$U(\omega )={\omega}_{0}/[{(a+j\omega )}^{2}+{w}_{0}{}^{2}]$$
Using U(ω) and G(ω) you can then get the frequencydomain expression for the outputs:
$$Y(\omega )=G(\omega )U(\omega )$$
You can now evaluate the analytical expressions for Y(ω)
and U(ω) over a grid of
frequency values $$({\omega}_{grid}={\omega}_{1},{\omega}_{2},\mathrm{...},{\omega}_{n})$$,
and get a vector of frequencydomain inputoutput data values $$({Y}_{grid},{U}_{grid})$$.
You can package the inputoutput data as a continuoustime iddata
object
by specifying a zero sample time, Ts
.
Ts = 0;
zf = iddata(Ygrid,Ugrid,Ts,'Frequency',wgrid)
Compute the frequency response of a continuoustime linear system at a grid of frequencies.
For example, in the following code, you generate continuoustime
frequencyresponse data, FRDc
, from a continuoustime
transfer function model, sys
for a grid of frequencies, freq
.
sys = idtf(1,[1 2 2]); freq = logspace(2,2,100); FRDc = idfrd(sys,freq);
Measure amplitudes and phases from a sinusoidal experiment,
where the measurement system uses antialiasing filters. You measure
the response of the system to sinusoidal inputs at different frequencies,
and package the data as an idfrd
object. For
example, the frequencyresponse data measured with a spectrum analyzer
is continuoustime.
You can also conduct an experiment by using periodic, continuoustime
signals (multiple sine waves) as inputs to your system and measuring
the response of your system. Then you can package the input and output
data as an iddata
object.
You can obtain discretetime frequencydomain data
(Ts
>0) in the following ways:
Transform the measured timedomain values using a discrete Fourier transform.
For example, in the following code, you compute the discrete
Fourier transform of timedomain data, y
, that
is measured at discrete timepoints with sample time 0.01 seconds.
t = 0:0.01:10; y = iddata(sin(2*pi*10*t),[],0.01); Y = fft(y);
Compute the frequency response of a discretetime linear system.
For example, in the following code, you generate discretetime
frequencyresponse data, FRDd
, from a discretetime
transfer function model, sys
. You specify a nonzero
sample time for creating the discretetime model.
Ts = 1; sys = idtf(1,[1 0.2 2.1],Ts); FRDd = idfrd(sys,logspace(2,2,100));
You can use continuoustime frequencydomain data to identify only continuoustime models. You can use discretetime frequencydomain data to identify both discretetime and continuoustime models. However, identifying continuoustime models from discretetime data requires knowledge of the intersample behavior of the data. For more information, see Estimating ContinuousTime and DiscreteTime Models.
For discretetime data, the software ignores frequencydomain data above the Nyquist frequency during estimation.
After you have represented your frequencydomain data using iddata
or idfrd
objects,
you can prepare the data for estimation by removing spurious data
and by filtering the data.
To view the spurious data, plot the data in the app, or use
the plot
(for iddata
objects)
or bode
(for idfrd
objects)
commands. After identifying the spurious data in the plot, you can
remove them. For example, if you want to remove data points 20–30
from zf
, a frequencydomain iddata
object,
use the following syntax:
zf(20:30) = [];
Since frequencydomain data does not have to be specified with a uniform spacing, you do not need to replace the outliers.
You can also prefilter highfrequency noise in your data. You
can prefilter frequencydomain data in the app, or use idfilt
at the command line. Prefiltering
data can also help remove drifts that are lowfrequency disturbances.
In addition to minimizing noise, prefiltering lets you focus your
model on specific frequency bands. The frequency range of interest
often corresponds to a passband over the breakpoints on a Bode plot.
For example, if you are modeling a plant for controldesign applications,
you can prefilter the data to enhance frequencies around the desired
closedloop bandwidth.
For more information, see Filtering Data.
After you have preprocessed the frequencydomain data, you can use it to estimate continuoustime and discretetime models.
You can estimate the following linear parametric models using frequencydomain data. The noise component of the models is not estimated, except for ARX models.
Model Type  Additional Information  Estimation Commands  Estimation in the App 

Transfer Function Models  See Estimate Transfer Function Models in the System Identification App.  
StateSpace Models  Estimated K matrix of the statespace model
is zero.  See Estimate StateSpace Models in System Identification App.  
Process Models  Disturbance model is not estimated.  See Estimate Process Models Using the App.  
InputOutput Polynomial Models  You can estimate only outputerror and ARX models.  See Estimate Polynomial Models in the App.  
Linear GreyBox Models  Model parameters that are only related to the noise matrix K are
not estimated.  Greybox model estimation is not available in the app.  
Correlation Models (Impulseresponse models)  See Estimate ImpulseResponse Models Using System Identification App.  
FrequencyResponse Models (Estimated as idfrd objects)  See Estimate FrequencyResponse Models in the App. 
Before performing the estimation, you can specify estimation
options, such as how the software treats initial conditions of the
estimation data. To do so at the command line, use the estimation
option set corresponding to the estimation command. For example, suppose
that you want to estimate a transfer function model from frequencydomain
data, zf
, and you also want to estimate the initial
conditions of the data. Use the tfestOptions
option
set to specify the estimation options, and then estimate the model.
opt = tfestOptions('InitialCondition','estimate'); sys = tfest(zf,opt);
sys
is the estimated transfer function model.
For information about extracting estimated parameter values from the
model, see Extracting Numerical Model Data. After
performing the estimation, you can validate the estimated model.
A zero initial condition for timedomain data does not imply a zero initial condition for the corresponding frequencydomain data. For timedomain data, zero initial conditions mean that the system is assumed to be in a state of rest before the start of data collection. In the frequencydomain, initial conditions can be ignored only if the data collected is periodic in nature. Thus, if you have timedomain data collected with zero initial conditions, and you convert it to frequencydomain data to estimate a model, you have to estimate the initial conditions as well. You cannot specify them as zero.
You cannot perform the following estimations using frequencydomain data:
Estimation of the noise component of a linear model, except for ARX models.
Estimation of time series models using spectrum data
only. Spectrum data is the power spectrum of a signal, commonly stored
in the SpectrumData
property of an idfrd
object.
You can estimate all the supported linear models as discretetime models, except for process models. Process models are defined in continuoustime only. For the estimation of discretetime models, you must use discretetime data.
You can estimate all the supported linear models as continuoustime
models, except for correlation models (see impulseest
).
You can estimate continuoustime models using both continuoustime
and discretetime data. For information about continuoustime and
discretetime data, see ContinuousTime and DiscreteTime FrequencyDomain Data.
If you are estimating a continuoustime model using discretetime data, you must specify the intersample behavior of the data. The specification of intersample behavior depends on the type of frequencydomain data.
Discretetime frequencydomain inputoutput data
(iddata
object) — Specify the intersample
behavior of the timedomain input signal u(t)
that you Fourier transformed to obtain the frequencydomain input
signal U(ω).
Discretetime frequencyresponse data (idfrd
object)
— The data is generated by computing the frequencyresponse
of a discretetime model. Specify the intersample behavior as the
discretization method assumed to compute the discretetime model from
an underlying continuoustime model. For an example, see Specify Intersample Behavior for DiscreteTime FrequencyResponse Data.
You can specify the intersample behavior to be piecewise constant (zeroorder hold), linearly interpolated between the samples (firstorder hold), or bandlimited. If you specify the discretetime data from your system as bandlimited (that is no power above the Nyquist frequency), the software treats the data as continuoustime by setting the sample time to zero. The software then estimates a continuoustime model from the data. For more information, see Effect of Input Intersample Behavior on ContinuousTime Models.
This example shows the effect of intersample behavior on the estimation of continuoustime models using discretetime frequencyresponse data.
Generate discretetime frequencyresponse data. To do so, first construct a continuoustime transfer function model, sys
. Then convert it to a discretetime model, sysd
, using the c2d
command and firstorder hold (FOH) method. Use the discretetime model sysd
to generate frequencyresponse data at specified frequencies, freq
.
sys = idtf([1 0.2],[1 2 1 1]); sysd = c2d(sys,1,c2dOptions('Method','foh')); freq = logspace(1,0,10); FRdata = idfrd(sysd,freq);
FRdata
is discretetime data. The software sets the InterSample
property of FRdata
to 'foh'
, which is the discretization method that was used to obtain sysd
from sys
.
Estimate a thirdorder continuoustime transfer function from the discretetime data.
model1 = tfest(FRdata,3,1)
model1 = s + 0.2  s^3 + 2 s^2 + s + 1 Continuoustime identified transfer function. Parameterization: Number of poles: 3 Number of zeros: 1 Number of free coefficients: 5 Use "tfdata", "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using TFEST on frequency response data "FRdata". Fit to estimation data: 100% FPE: 8.88e31, MSE: 1.303e31
model1
is a continuoustime model, estimated using discretetime frequencyresponse data. The underlying continuoustime dynamics of the original thirdorder model sys
are retrieved in model1
because the correct intersample behavior is specified in FRdata
.
Now, specify the intersample behavior as zeroorder hold (ZOH), and estimate a thirdorder transfer function model.
FRdata.InterSample = 'zoh';
model2 = tfest(FRdata,3,1)
model2 = 15.58 s  3.291  s^3  30.04 s^2  6.962 s  17.01 Continuoustime identified transfer function. Parameterization: Number of poles: 3 Number of zeros: 1 Number of free coefficients: 5 Use "tfdata", "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using TFEST on frequency response data "FRdata". Fit to estimation data: 94.91% FPE: 0.004496, MSE: 0.0015
model2
does not capture the dynamics of the original model sys
. Thus, sampling related errors are introduced in the model estimation when the intersample behavior is not correctly specified.
This example shows how to convert a frequencyresponse data (FRD) model to a transfer function model. You treat the FRD model as estimation data and then estimate the transfer function.
Obtain an FRD model.
For example, use bode
to obtain the magnitude and phase response data for the following fifthorder system:
$$G(s)=\frac{s+0.2}{{s}^{5}+{s}^{4}+0.8{s}^{3}+0.4{s}^{2}+0.12s+0.04}$$
Use 100 frequency points between 0.1 rad/s to 10 rad/s to obtain the FRD model. Use frd
to create a frequencyresponse model object.
freq = logspace(1,1,100); sys0 = tf([1 0.2],[1 1 0.8 0.4 0.12 0.04]); [mag,phase] = bode(sys0,freq); frdModel = frd(mag.*exp(1j*phase*pi/180),freq);
Obtain the best thirdorder approximation to the system dynamics by estimating a transfer function with 3 zeros and 3 poles.
np = 3; nz = 3; sys = tfest(frdModel,np,nz);
sys
is the estimated transfer function.
Compare the response of the FRD Model and the estimated transfer function model.
bode(frdModel,sys,freq(1:50));
The FRD model is generated from the fifthorder system sys0
. While sys
, a thirdorder approximation, does not capture the entire response of sys0
, it captures the response well until approximately 0.6 rad/s.
After estimating a model for your system, you can validate whether
it reproduces the system behavior within acceptable bounds. It is
recommended that you use separate data sets for estimating and validating
your model. You can use timedomain or frequencydomain data to validate
a model estimated using frequencydomain data. If you are using inputoutput
validation data to validate the estimated model, you can compare the
simulated model response to the measured validation data output. If
your validation data is frequencyresponse data, you can compare it
to the frequency response of the model. For example, to compare the
output of an estimated model sys
to measured validation
data zv
, use the following syntax:
compare(zv,sys);
You can also perform a residual analysis. For more information see, Validating Models After Estimation.
When you estimate a model using frequencydomain data, the estimation
algorithm minimizes a loss (cost) function. For example, if you estimate
a SISO linear model from frequencyresponse data f
,
the estimation algorithm minimizes the following leastsquares loss
function:
$$\underset{G(\omega )}{\text{minimize}}{\displaystyle \sum _{k=1}^{{N}_{f}}{\leftW({\omega}_{k})\left(G({\omega}_{k})f({\omega}_{k})\right)\right}^{2}}$$
Here W
is a frequencydependent
weight that you specify, G
is the linear model
that is to be estimated, ω is the frequency, and N_{f} is
the number of frequencies at which the data is available. The quantity $$\left(G({\omega}_{k})f({\omega}_{k})\right)$$ is
the frequencyresponse error. For frequencydomain inputoutput data,
the algorithm minimizes the weighted norm of the output error instead
of the frequencyresponse error. For more information, see Loss Function and Model Quality Metrics. During estimation,
spurious or uncaptured dynamics in your data can effect the loss function
and result in unsatisfactory model estimation.
Unexpected, spurious dynamics — Typically observed when the high magnitude regions of data have low signaltonoise ratio. The fitting error around these portions of data has a large contribution to the loss function. As a result the estimation algorithm may overfit and assign unexpected dynamics to noise in these regions. To troubleshoot this issue:
Improve signaltonoise ratio — You can gather
more than one set of data, and average them. If you have frequencydomain
inputoutput data, you can combine multiple data sets by using the merge
command. Use this data for estimation
to obtain an improved result. Alternatively, you can filter the dataset,
and use it for estimation. For example, use a movingaverage filter
over the data to smooth the measured response. Apply the smoothing
filter only in regions of data where you are confident that the unsmoothness
is due to noise, and not due to system dynamics.
Reduce the impact of certain portions of data on the
loss function — You can specify a frequencydependent weight.
For example, if you are estimating a transfer function model, specify
the weight in the WeightingFilter
option of the
estimation option set tfestOptions
.
Specify a small weight in frequency regions where the spurious dynamics
exist. Alternatively, use fewer data points around this frequency
region.
Uncaptured dynamics — Typically observed when the dynamics you want to capture have a low magnitude relative to the rest of data. Since a poor fit to low magnitude data contributes less to the loss function, the algorithm may ignore these dynamics to reduce errors at other frequencies. To troubleshoot this issue:
Specify a frequencydependent weight — Specify a large weight for the frequency region where you would like to capture dynamics.
Use more data points around this region.
For an example of these troubleshooting techniques, see Troubleshoot FrequencyDomain Identification of Transfer Function Models.
If you do not achieve a satisfactory model using these troubleshooting techniques, try a different model structure or estimation algorithm.
After estimating a model, you can perform model transformations, extract model parameters, and simulate and predict the model response. Some of the tasks you can perform are:
Transforming Between DiscreteTime and ContinuousTime Representations
Transforming Between Linear Model Representations — Transform between linear parametric model representations, such as between polynomial, statespace, and zeropole representations.
Extracting Numerical Model Data —
For example, extract the poles and zeros of the model using pole
and zero
commands,
respectively. Compute the model frequency response for a specified
set of frequencies using freqresp
.