Documentation |
Transfer function models describe the relationship between the inputs and outputs of a system using a ratio of polynomials. The model order is equal to the order of the denominator polynomial. The roots of the denominator polynomial are referred to as the model poles. The roots of the numerator polynomial are referred to as the model zeros.
The parameters of a transfer function model are its poles, zeros and transport delays.
In continuous-time, a transfer function model has the form:
$$Y(s)=\frac{num(s)}{den(s)}U(s)+E(s)$$
Where, Y(s), U(s) and E(s) represent the Laplace transforms of the output, input and noise, respectively. num(s) and den(s) represent the numerator and denominator polynomials that define the relationship between the input and the output.
In discrete-time, a transfer function model has the form:
$$\begin{array}{l}y(t)=\frac{num({q}^{-1})}{den({q}^{-1})}u(t)+e(t)\\ num({q}^{-1})={b}_{0}+{b}_{1}{q}^{-1}+{b}_{2}{q}^{-2}+\dots \\ den({q}^{-1})=1+{a}_{1}{q}^{-1}+{a}_{2}{q}^{-2}+\dots \end{array}$$
The roots of num(q^-1) and den(q^-1) are expressed in terms of the lag variable q^-1.
In continuous-time, input and transport delays are of the form:
$$Y(s)=\frac{num(s)}{den(s)}{e}^{-s\tau}U(s)+E(s)$$
Where τ represents the delay.
In discrete-time:
$$y(t)=\frac{num}{den}u(t-\tau )+e(t)$$
where num and den are polynomials in the lag operator q^(-1).
You can estimate transfer function models from data with the following characteristics:
Real data or complex data
Single-output and multiple-output
Time- or frequency-domain data
Note that you cannot use time-series data for transfer function model identification.
You must first import your data into the MATLAB^{®} workspace, as described in Data Preparation.
In the System Identification app, select Estimate > Transfer Function Models
The Transfer Functions dialog box opens.
In the Number of poles and Number of zeros fields, specify the number of poles and zeros of the transfer function as nonnegative integers.
Select Continuous-time or Discrete-time to specify whether the model is a continuous- or discrete-time transfer function.
For discrete-time models, the number of poles and zeros refers to the roots of the numerator and denominator polynomials expressed in terms of the lag variable q^-1.
(For discrete-time models only) Specify whether to estimate the model feedthrough. Select the Feedthrough check box.
A discrete-time model with 2 poles and 3 zeros takes the following form:
$$H{z}^{-1}=\frac{b0+b1{z}^{-1}+b2{z}^{-2}+b3{z}^{-3}}{1+a1{z}^{-1}+a2{z}^{-2}}$$
When the model has direct feedthrough, b0 is a free parameter whose value is estimated along with the rest of the model parameters b1, b2, b3, a1, a2. When the model has no feedthrough, b0 is fixed to zero.
Expand the I/O Delay section to specify nominal values and constraints for transport delays for different input/output pairs.
Use the Output list to select an output. Select the Fixed check box to specify a transport delay as a fixed value. Specify its nominal value in the Delay field.
Expand the Estimation Options section to specify estimation options.
Set the range slider to the desired passband to specify the frequency range over which the transfer function model must fit the data. By default the entire frequency range (0 to Nyquist frequency) is covered.
Select Display progress to view the progress of the optimization.
Select Estimate covariance to estimate the covariance of the transfer function parameters.
(For frequency-domain data only) Specify whether to allow the estimation process to use parameter values that may lead to unstable models. Select the Allow unstable models option.
Setting this option is same as setting the estimation option Focus to 'prediction' at the command line. An unstable model is delivered only if it produces a better fit to the data than other stable models computed during the estimation process.
Specify how to treat the initial conditions in the Initial condition list. For more information, see Specifying Initial Conditions for Iterative Estimation Algorithms.
Specify the algorithm used to initialize the values of the numerator and denominator coefficients in the Initialization method list.
IV — Instrument Variable approach.
SVF — State Variable Filters approach.
N4SID — Generalized Poisson Moment Functions approach.
GPMF — Subspace state-space estimation approach.
All — Combination of all of the above approaches. The software tries all the above methods and selects the method that yields the smallest value of prediction error norm.
Click Regularization to obtain regularized estimates of model parameters. Specify the regularization constants in the Regularization Options dialog box. To learn more, see Regularized Estimates of Model Parameters.
Click Iterations Options to specify options for controlling the iterations. The Options for Iterative Minimization dialog box opens.
Click Estimate to estimate the model. A new model gets added to the System Identification app.
Before you estimate a transfer function model, you must have:
Input/Output data. See Representing Time- and Frequency-Domain Data Using iddata Objects. For supported data formats, see Data Supported by Transfer Function Models.
Performed any required data preprocessing operations. You can detrend your data before estimation. For more information, see Ways to Prepare Data for System Identification.
Alternatively, you can specify the input/output offset for the data using an estimation option set. Use tfestOptions to create the estimation option set. Use the InputOffset and OutputOffset name and value pairs to specify the input/output offset.
Estimate continuous-time and discrete-time transfer function models using tfest. The output of tfest is an idtf object, which represents the identified transfer function.
The general workflow in estimating a transfer function model is:
Create a data object (iddata or idfrd) that captures the experimental data.
(Optional) Specify estimation options using tfestOptions.
(Optional) Create a transfer function model that specifies the expected model structure and any constraints on the estimation parameters.
Use tfest to identify the transfer function model, based on the data.
Validate the model. See Model Validation.
You can use a priori knowledge of the expected transfer function model structure to initialize the estimation. The Structure property of an idtf model contains parameters that allow you to specify the values and constraints for the numerator, denominator and transport delays.
For example, specify a third-order transfer function model that contains an integrator and has a transport delay of at most 1.5 seconds:
init_sys = idtf([nan nan],[1 2 1 0]); init_sys.Structure.ioDelay.Maximum = 1.5; init_sys.Structure.den.Free(end) = false;
int_sys is an idtf model with three poles and one zero. The denominator coefficient for the s^0 term is zero and implies that one of the poles is an integrator.
init_sys.Structure.ioDelay.Maximum = 1.5 constrains the transport delay to a maximum of 1.5 seconds. The last element of the denominator coefficients (associated with the s^0 term) is not a free estimation variable. This constraint forces one of the estimated poles to be at s = 0.
For more information regarding configuring the initial parameterization of an estimated transfer function, see Structure in idtf.
This example shows how to identify a transfer function containing a specified number of poles for given data.
Load time-domain system response data and use it to estimate a transfer function for the system.
load iddata1 z1; np = 2; sys = tfest(z1,np);
z1 is an iddata object that contains time-domain, input-output data.
np specifies the number of poles in the estimated transfer function.
sys is an idtf model containing the estimated transfer function.
To see the numerator and denominator coefficients of the resulting estimated model sys, enter:
sys.num sys.den
To view the uncertainty in the estimates of the numerator and denominator and other information, use tfdata.
This example shows how to identify a transfer function to fit a given frequency response data (FRD) containing additional phase roll off induced by input delay.
Obtain frequency response data.
For this example, use bode to obtain the magnitude and phase response data for the following system:
$$H(s)={e}^{-.5s}\frac{s+0.2}{{s}^{3}+2{s}^{2}+s+1}$$
Use 100 frequency points, ranging from 0.1 rad/s to 10 rad/s, to obtain the frequency response data. Use frd to create a frequency response data object.
freq = logspace(-1,1,100);
[mag, phase] = bode(tf([1 .2],[1 2 1 1],'InputDelay',.5),freq);
data = frd(mag.*exp(1j*phase*pi/180),freq);
data is an iddata object that contains frequency response data for the described system.
Estimate a transfer function using data. Specify an unknown transport delay for the identified transfer function.
np = 3; nz = 1; iodelay = NaN; sys = tfest(data,np,nz,iodelay)
np and nz specify the number of poles and zeros in the identified transfer function, respectively.
iodelay specifies an unknown transport delay for the identified transfer function.
sys is an idtf model containing the identified transfer function.
This example shows how to estimate a transfer function for given data when the structure of the expected model is known. This example also shows how to apply constraints to the numerator and denominator coefficients.
Load time domain data.
load iddata1 z1; z1.y = cumsum(z1.y);
cumsum integrates the output data of z1. The estimated transfer function should therefore contain an integrator.
Create a transfer function model with the expected structure.
init_sys = idtf([100 1500],[1 10 10 0]);
int_sys is an idtf model with three poles and one zero. The denominator coefficient for the s^0 term is zero. Therefore, int_sys contains an integrator.
Specify constraints on the numerator and denominator coefficients of the transfer function model. To do so, configure fields in the Structure property:
init_sys.Structure.num.Minimum = eps; init_sys.Structure.den.Minimum = eps; init_sys.Structure.den.Free(end) = false;
The constraints specify that the numerator and denominator coefficients are nonnegative. Additionally, the last element of the denominator coefficients (associated with the s^0 term) is not an estimable parameter. This constraint forces one of the estimated poles to be at s = 0.
Create an estimation option set that specifies using the Levenberg–Marquardt search method.
opt = tfestOptions('SearchMethod', 'lm');
Estimate a transfer function for z1 using init_sys and the estimation option set.
sys = tfest(z1,init_sys,opt);
tfest uses the coefficients of init_sys to initialize the estimation of sys. Additionally, the estimation is constrained by the constraints you specify in the Structure property of init_sys. The resulting idtf model sys contains the parameter values that result from the estimation.
This example shows how to estimate a transfer function for given data with unknown transport delays. This example also shows how to apply an upper bound on the unknown transport delays.
Create a transfer function model with the expected numerator and denominator structure and delay constraints.
For this example, the experiment data consists of two inputs and one output. Both transport delays are unknown and have an identical upper bound. Additionally, the transfer functions from both inputs to the output are identical in structure.
init_sys = idtf(NaN(1,2),[1, NaN(1,3)],'ioDelay',NaN);
init_sys.Structure(1).ioDelay.Free = true;
init_sys.Structure(1).ioDelay.Maximum = 7;
init_sys is an idtf model describing the structure of the transfer function from one input to the output. The transfer function consists of one zero, three poles and a transport delay. The use of NaN indicates unknown coefficients.
init_sys.Structure(1).ioDelay.Free = true indicates that the transport delay is not fixed.
init_sys.Structure(1).ioDelay.Maximum = 7 sets the upper bound for the transport delay to 7 seconds.
Specify the transfer function from both inputs to the output.
init_sys = [init_sys, init_sys];
Load time domain system response data and detrend .
load co2data;
Ts = 0.5;
data = iddata(Output_exp1,Input_exp1,Ts);
T = getTrend(data);
T.InputOffset = [170, 50];
T.OutputOffset = mean(data.y(1:75));
data = detrend(data, T);
data is an iddata object and has a sample rate of 0.5 seconds.
Identify a transfer function for the measured data using the specified delay constraints.
sys = tfest(data,init_sys);
sys is an idtf model containing the identified transfer function.
This example shows how to estimate transfer function models with I/O delays.
The tfest command supports estimation of IO delays. In the simplest case, if you specify NaN as the value for the ioDelay input argument, tfest estimates the corresponding delay value.
load iddata1 z1 sys = tfest(z1, 2, 2, NaN); % 2 poles, 2 zeros, unknown transport delay
If you want to assign an initial guess to the value of delay or prescribe bounds for its value, you must first create a template idtf model and configure ioDelay using the model's Structure property:
sys0 = idtf([nan nan nan],[1 nan nan]); sys0.Structure.ioDelay.Value = 0.1; % initial guess sys0.Structure.ioDelay.Maximum = 1; % maximum allowable value for delay sys0.Structure.ioDelay.Free = true; % treat delay as estimatable quantity sys = tfest(z1, sys0);
If estimation data is in the time-domain, the delays are not estimated iteratively. If a finite initial value is specified, that value is retained as is with no iterative updates. The same is true of discrete-time frequency domain data. Thus in the example above, if data has a nonzero sample time, the estimated value of delay in the returned model sys is 0.1 (same as the initial guess specified for sys0 ). The delays are updated iteratively only for continuos-time frequency domain data. If, on the other hand, a finite initial value for delay is not specified (e.g., sys0.Structure.ioDelay.Value = NaN ), then a value for delay is determined using the delayest function, regardless of the nature of the data.
Determination of delay as a quantity independent of the model's poles and zeros is a difficult task. Estimation of delays becomes especially difficult for multi-input or multi-output data. It is strongly recommended that you perform some investigation to determine delays before estimation. You can use functions such as delayest, arxstruc, selstruc and impulse response analysis to determine delays. Often, physical knowledge of the system or dedicated transient tests (how long does it take for a step change in input to show up in a measured output?) will reveal the value of transport delays. Use the results of such analysis to assign initial guesses as well as minimum and maximum bounds on the estimated values of delays.
If you estimate transfer function models using tfest, you can specify how the algorithm treats initial conditions.
In the System Identification app, set Initial condition to one of the following options:
auto — Automatically chooses Zero, Estimate, or Backcast based on the estimation data. If initial conditions have negligible effect on the prediction errors, the initial conditions are set to zero to optimize algorithm performance.
Zero — Sets all initial conditions to zero.
Estimate — Treats the initial conditions as an estimation parameters.
Backcast — Estimates initial conditions using a backward filtering method (least-squares fit).
At the command line. Specify the initial conditions by using an estimation option set. Use tfestOptions to create the estimation option set. For example, create an options set that sets the initial conditions to zero:
opt = tfestOptions('InitialCondition','zero);
For more information, see tfestOptions.