Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

This example shows how to estimate models using frequency domain data. The estimation and validation of models using frequency domain data work the same way as they do with time domain data. This provides a great amount of flexibility in estimation and analysis of models using time and frequency domain as well as spectral (FRF) data. You may simultaneously estimate models using data in both domains, compare and combine these models. A model estimated using time domain data may be validated using spectral data or vice-versa.

Frequency domain data cannot be used for estimation or validation of nonlinear models.

Frequency domain experimental data are common in many applications. It could be that the data was collected as frequency response data (frequency functions: FRF) from the process using a frequency analyzer. It could also be that it is more practical to work with the input's and output's Fourier transforms (FFT of time-domain data), for example to handle periodic or band-limited data. (A band-limited continuous time signal has no frequency components above the Nyquist frequency). In System Identification Toolbox, frequency domain I/O data are represented the same way as time-domain data, i.e., using `iddata`

objects. The 'Domain' property of the object must be set to 'Frequency'. Frequency response data are represented as complex vectors or as magnitude/phase vectors as a function of frequency. IDFRD objects in the toolbox are used to encapsulate FRFs, where a user specifies the complex response data and a frequency vector. Such IDDATA or IDFRD objects (and also FRD objects of Control System Toolbox) may be used seamlessly with any estimation routine (such as `procest`

, `tfest`

etc).

Let us begin by loading some frequency domain data:

```
load demofr
```

This MAT-file contains frequency response data at frequencies `W`

, with the amplitude response `AMP`

and the phase response `PHA`

. Let us first have a look at the data:

subplot(211), loglog(W,AMP),title('Amplitude Response') subplot(212), semilogx(W,PHA),title('Phase Response')

This experimental data will now be stored as an IDFRD object. First transform amplitude and phase to a complex valued response:

zfr = AMP.*exp(1i*PHA*pi/180); Ts = 0.1; gfr = idfrd(zfr,W,Ts);

`Ts`

is the sample time of the underlying data. If the data corresponds to continuous time, for example since the input has been band-limited, use Ts = 0.

Note: If you have the Control System Toolbox™, you could use an FRD object instead of the IDFRD object. IDFRD has options for more information, like disturbance spectra and uncertainty measures which are not available in FRD objects.

The IDFRD object `gfr`

now contains the data, and it can be plotted and analyzed in different ways. To view the data, we may use `plot`

or `bode`

:

```
clf
bode(gfr), legend('gfr')
```

To estimate models, you can now use `gfr`

as a data set with all the commands of the toolbox in a transparent fashion. The only restriction is that noise models cannot be built. This means that for polynomial models only OE (output-error models) apply, and for state-space models, you have to fix `K = 0`

.

m1 = oe(gfr,[2 2 1]) % Discrete-time Output error (transfer function) model ms = ssest(gfr) % Continuous-time state-space model with default choice of order mproc = procest(gfr,'P2UDZ') % 2nd-order, continuous-time model with underdamped poles compare(gfr,m1,ms,mproc) L = findobj(gcf,'type','legend'); L.Location = 'southwest'; % move legend to non-overlapping location

m1 = Discrete-time OE model: y(t) = [B(z)/F(z)]u(t) + e(t) B(z) = 0.9986 z^-1 + 0.4968 z^-2 F(z) = 1 - 1.499 z^-1 + 0.6998 z^-2 Sample time: 0.1 seconds Parameterization: Polynomial orders: nb=2 nf=2 nk=1 Number of free coefficients: 4 Use "polydata", "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using OE on frequency response data "gfr". Fit to estimation data: 88.55% FPE: 0.2492, MSE: 0.2482 ms = Continuous-time identified state-space model: dx/dt = A x(t) + B u(t) + K e(t) y(t) = C x(t) + D u(t) + e(t) A = x1 x2 x1 -0.9009 6.635 x2 -3.307 -2.668 B = u1 x1 -32.9 x2 -28.33 C = x1 x2 y1 -0.5073 0.499 D = u1 y1 0 K = y1 x1 0 x2 0 Parameterization: FREE form (all coefficients in A, B, C free). Feedthrough: none Disturbance component: none Number of free coefficients: 8 Use "idssdata", "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using SSEST on frequency response data "gfr". Fit to estimation data: 88.55% FPE: 0.2492, MSE: 0.2482 mproc = Process model with transfer function: 1+Tz*s G(s) = Kp * ---------------------- * exp(-Td*s) 1+2*Zeta*Tw*s+(Tw*s)^2 Kp = 7.4619 Tw = 0.20245 Zeta = 0.36242 Td = 0 Tz = 0.013617 Parameterization: 'P2DUZ' Number of free coefficients: 5 Use "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using PROCEST on frequency response data "gfr". Fit to estimation data: 88.55% FPE: 0.2495, MSE: 0.2482

As shown above a variety of linear model types may be estimated in both continuous and discrete time domains, using spectral data. These models may be validated using, time-domain data. The time-domain I/O data set `ztime`

, for example, is collected from the same system, and can be used for validation of `m1`

, `ms`

and `mproc`

:

```
compare(ztime,m1,ms,mproc) %validation in a different domain
```

We may also look at the residuals to affirm the quality of the model using the validation data `ztime`

. As observed, the residuals are almost white:

```
resid(ztime,mproc) % Residuals plot
```

An important reason to work with frequency response data is that it is easy to condense the information with little loss. The command SPAFDR allows you to compute smoothed response data over limited frequencies, for example with logarithmic spacing. Here is an example where the `gfr`

data is condensed to 100 logarithmically spaced frequency values. With a similar technique, also the original time domain data can be condensed:

sgfr = spafdr(gfr) % spectral estimation with frequency-dependent resolution sz = spafdr(ztime); % spectral estimation using time-domain data clf bode(gfr,sgfr,sz) axis([pi/100 10*pi, -272 105]) legend('gfr (raw data)','sgfr','sz','location','southwest')

sgfr = IDFRD model. Contains Frequency Response Data for 1 output(s) and 1 input(s), and the spectra for disturbances at the outputs. Response data and disturbance spectra are available at 100 frequency points, ranging from 0.03142 rad/s to 31.42 rad/s. Sample time: 0.1 seconds Output channels: 'y1' Input channels: 'u1' Status: Estimated using SPAFDR on frequency response data "gfr".

The Bode plots show that the information in the smoothed data has been taken well care of. Now, these data records with 100 points can very well be used for model estimation. For example:

```
msm = oe(sgfr,[2 2 1]);
compare(ztime,msm,m1) % msm has the same accuracy as M1 (based on 1000 points)
```

It may be that the measurements are available as Fourier transforms of inputs and output. Such frequency domain data from the system are given as the signals Y and U. In loglog plots they look like

Wfd = (0:500)'*10*pi/500; subplot(211),loglog(Wfd,abs(Y)),title('The amplitude of the output') subplot(212),loglog(Wfd,abs(U)),title('The amplitude of the input')

The frequency response data is essentially the ratio between `Y`

and `U`

. To collect the frequency domain data as an IDDATA object, do as follows:

ZFD = iddata(Y, U, 'Ts', 0.1, 'Frequency', Wfd)

ZFD = Frequency domain data set with responses at 501 frequencies, ranging from 0 to 31.416 rad/seconds Sample time: 0.1 seconds Outputs Unit (if specified) y1 Inputs Unit (if specified) u1

Now, again the frequency domain data set `ZFD`

can be used as data in all estimation routines, just as time domain data and frequency response data:

mf = ssest(ZFD) % SSEST picks best order in 1:10 range when called this way mfr = ssregest(ZFD) % an alternative regularized reduction based state-space estimator clf compare(ztime,mf,mfr,m1)

mf = Continuous-time identified state-space model: dx/dt = A x(t) + B u(t) + K e(t) y(t) = C x(t) + D u(t) + e(t) A = x1 x2 x1 -1.501 6.791 x2 -3.115 -2.059 B = u1 x1 -28.11 x2 -33.39 C = x1 x2 y1 -0.5844 0.4129 D = u1 y1 0 K = y1 x1 0 x2 0 Parameterization: FREE form (all coefficients in A, B, C free). Feedthrough: none Disturbance component: none Number of free coefficients: 8 Use "idssdata", "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using SSEST on frequency domain data "ZFD". Fit to estimation data: 97.21% FPE: 0.0423, MSE: 0.04179 mfr = Discrete-time identified state-space model: x(t+Ts) = A x(t) + B u(t) + K e(t) y(t) = C x(t) + D u(t) + e(t) A = x1 x2 x3 x4 x5 x6 x1 0.7607 0.3671 -0.3322 -0.08998 0.01548 0.09474 x2 -0.227 -0.4068 -0.3153 0.233 -0.1859 0.2795 x3 0.262 -0.3038 0.6404 0.1926 -0.02235 -0.2056 x4 -0.0205 -0.1497 0.03978 -0.1501 -0.353 -0.3459 x5 0.03394 0.01352 0.2328 -0.4938 -0.2778 -0.09414 x6 0.01766 0.3918 0.1908 0.2817 -0.0382 0.141 x7 -0.03115 -0.3107 -0.02915 -0.2754 0.3491 0.5479 x8 0.01892 0.06892 0.09164 -0.1246 -0.4316 0.01104 x9 -0.003668 -0.1277 -0.1057 0.03904 0.1206 -0.423 x10 0.0174 0.04442 -0.02417 0.1074 0.02164 -0.2264 x7 x8 x9 x10 x1 -0.1456 0.007799 0.05833 -0.1396 x2 -0.336 0.009541 0.2668 -0.1218 x3 0.233 -0.1177 0.03473 -0.06575 x4 -0.1299 0.166 0.1195 -0.2518 x5 -0.6382 -0.2387 0.04806 0.04836 x6 -0.2343 -0.4258 0.6103 -0.1953 x7 -0.2887 -0.6828 0.136 -0.4042 x8 0.5226 -0.2932 -0.007668 0.09615 x9 -0.1939 -0.3768 -0.09409 0.507 x10 -0.02294 -0.6167 -0.4447 -0.5943 B = u1 x1 1.588 x2 -0.1338 x3 -0.09661 x4 -0.02391 x5 -0.02324 x6 0.03246 x7 0.0002968 x8 -0.03677 x9 0.06961 x10 -0.006027 C = x1 x2 x3 x4 x5 x6 x7 y1 0.7727 -0.5047 2.644 1.195 -0.5607 1.542 -1.08 x8 x9 x10 y1 0.06959 -0.9512 0.2948 D = u1 y1 0 K = y1 x1 -0.0306 x2 -0.01498 x3 0.08894 x4 -0.04447 x5 0.04233 x6 -0.01548 x7 0.01024 x8 -0.0004959 x9 -0.003125 x10 -0.001307 Sample time: 0.1 seconds Parameterization: FREE form (all coefficients in A, B, C free). Feedthrough: none Disturbance component: estimate Number of free coefficients: 130 Use "idssdata", "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using SSREGEST on frequency domain data "ZFD". Fit to estimation data: 65.8% (prediction focus) FPE: 6.813, MSE: 6.289

Time and frequency domain input-output data sets can be transformed to either domain by using FFT and IFFT. These commands are adapted to IDDATA objects:

dataf = fft(ztime) datat = ifft(dataf)

dataf = Frequency domain data set with responses at 501 frequencies, ranging from 0 to 31.416 rad/seconds Sample time: 0.1 seconds Outputs Unit (if specified) y1 Inputs Unit (if specified) u1 datat = Time domain data set with 1000 samples. Sample time: 0.1 seconds Outputs Unit (if specified) y1 Inputs Unit (if specified) u1

Time and frequency domain input-output data can be transformed to frequency response data by SPAFDR, SPA and ETFE:

g1 = spafdr(ztime) g2 = spafdr(ZFD); clf; bode(g1,g2)

g1 = IDFRD model. Contains Frequency Response Data for 1 output(s) and 1 input(s), and the spectra for disturbances at the outputs. Response data and disturbance spectra are available at 100 frequency points, ranging from 0.06283 rad/s to 31.42 rad/s. Sample time: 0.1 seconds Output channels: 'y1' Input channels: 'u1' Status: Estimated using SPAFDR on time domain data "ztime".

Frequency response data can also be transformed to more smoothed data (less resolution and less data) by SPAFDR and SPA;

g3 = spafdr(gfr);

Frequency response data can be transformed to frequency domain input-output signals by the command IDDATA:

gfd = iddata(g3) plot(gfd)

gfd = Frequency domain data set with responses at 100 frequencies, ranging from 0.031416 to 31.416 rad/seconds Sample time: 0.1 seconds Outputs Unit (if specified) y1 Inputs Unit (if specified) u1

Time domain data can naturally only be stored and dealt with as discrete-time, sampled data. Frequency domain data have the advantage that continuous time data can be represented correctly. Suppose that the underlying continuous time signals have no frequency information above the Nyquist frequency, e.g. because they are sampled fast, or the input has no frequency component above the Nyquist frequency and that the data has been collected from a steady-state experiment. Then the Discrete Fourier transforms (DFT) of the data also are the Fourier transforms of the continuous time signals, at the chosen frequencies. They can therefore be used to directly fit continuous time models.

This will be illustrated by the following example.

Consider the continuous time system:

```
m0 = idpoly(1,1,1,1,[1 1 1],'ts',0)
```

m0 = Continuous-time OE model: y(t) = [B(s)/F(s)]u(t) + e(t) B(s) = 1 F(s) = s^2 + s + 1 Parameterization: Polynomial orders: nb=1 nf=2 nk=0 Number of free coefficients: 3 Use "polydata", "getpvec", "getcov" for parameters and their uncertainties. Status: Created by direct construction or transformation. Not estimated.

Load data that comes from steady-state simulation of this system using periodic inputs. The collected data was converted into frequency domain and saved in CTFDData.mat file.

load CTFDData.mat dataf % load continuous-time frequency-domain data.

Look at the data:

```
plot(dataf)
set(gca,'XLim',[0.1 10])
```

Using `dataf`

for estimation will by default give continuous time models: State-space:

```
m4 = ssest(dataf,2); %Second order continuous-time model
```

For a polynomial model with `nb = 2`

numerator coefficient and `nf = 2`

estimated denominator coefficients use:

nb = 2; nf = 2; m5 = oe(dataf,[nb nf])

m5 = Continuous-time OE model: y(t) = [B(s)/F(s)]u(t) + e(t) B(s) = -0.01826 s + 1.008 F(s) = s^2 + 1.001 s + 0.9967 Parameterization: Polynomial orders: nb=2 nf=2 nk=0 Number of free coefficients: 4 Use "polydata", "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using OE on frequency domain data "dataf". Fit to estimation data: 70.08% FPE: 0.004842, MSE: 0.004728

Compare step responses with uncertainty of the true system `m0`

and the models `m4`

and `m5`

. The confidence intervals are shown with patches in the plot.

clf h = stepplot(m0,m4,m5); showConfidence(h,1) legend('show','location','southeast')

Although it was not necessary in this case, it is generally advised to focus the fit to a limited frequency band (low pass filter the data) when estimating using continuous time data. The system has a bandwidth of about 3 rad/s, and was excited by sinusoids up to 6.2 rad/s. A reasonable frequency range to focus the fit to is then [0 7] rad/s:

m6 = ssest(dataf,2,ssestOptions('WeightingFilter',[0 7])) % state space model

m6 = Continuous-time identified state-space model: dx/dt = A x(t) + B u(t) + K e(t) y(t) = C x(t) + D u(t) + e(t) A = x1 x2 x1 -0.274 -1.809 x2 0.4403 -0.7283 B = u1 x1 0.5786 x2 -0.3114 C = x1 x2 y1 0.7686 1.485 D = u1 y1 0 K = y1 x1 0 x2 0 Parameterization: FREE form (all coefficients in A, B, C free). Feedthrough: none Disturbance component: none Number of free coefficients: 8 Use "idssdata", "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using SSEST on frequency domain data "dataf". Fit to estimation data: 87.08% (data prefiltered) FPE: 0.004804, MSE: 0.003682

m7 = oe(dataf,[1 2],oeOptions('WeightingFilter',[0 7])) % polynomial model of Output Error structure

m7 = Continuous-time OE model: y(t) = [B(s)/F(s)]u(t) + e(t) B(s) = 0.9866 F(s) = s^2 + 0.9791 s + 0.9761 Parameterization: Polynomial orders: nb=1 nf=2 nk=0 Number of free coefficients: 3 Use "polydata", "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using OE on frequency domain data "dataf". Fit to estimation data: 87.05% (data prefiltered) FPE: 0.004829, MSE: 0.0037

opt = procestOptions('SearchMethod','lsqnonlin',... 'WeightingFilter',[0 7]); % Requires Optimization Toolbox(TM) m8 = procest(dataf,'P2UZ',opt) % process model with underdamped poles

m8 = Process model with transfer function: 1+Tz*s G(s) = Kp * ---------------------- 1+2*Zeta*Tw*s+(Tw*s)^2 Kp = 1.0124 Tw = 1.0019 Zeta = 0.5021 Tz = -0.017474 Parameterization: 'P2UZ' Number of free coefficients: 4 Use "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using PROCEST on frequency domain data "dataf". Fit to estimation data: 87.08% (data prefiltered) FPE: 0.004804, MSE: 0.003682

opt = tfestOptions('SearchMethod','lsqnonlin',... 'WeightingFilter',[0 7]); % Requires Optimization Toolbox m9 = tfest(dataf,2,opt) % transfer function with 2 poles

m9 = From input "u1" to output "y1": -0.01662 s + 1.007 ------------------ s^2 + s + 0.995 Continuous-time identified transfer function. Parameterization: Number of poles: 2 Number of zeros: 1 Number of free coefficients: 4 Use "tfdata", "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using TFEST on frequency domain data "dataf". Fit to estimation data: 87.09% (data prefiltered) FPE: 0.004842, MSE: 0.003679

```
h = stepplot(m0,m6,m7,m8,m9);
showConfidence(h,1)
legend('show')
```

We saw how time, frequency and spectral data can seamlessly be used to estimate a variety of linear models in both continuous and discrete time domains. The models may be validated and compared in domains different from the ones they were estimated in. The data formats (time, frequency and spectrum) are interconvertible, using methods such as `fft`

, `ifft`

, `spafdr`

and `spa`

. Furthermore, direct, continuous-time estimation is achievable by using `tfest`

, `ssest`

and `procest`

estimation routines. The seamless use of data in any domain for estimation and analysis is an important feature of System Identification Toolbox.

Was this topic helpful?