Documentation Center 
Transfer function estimation
sys = tfest(data,np)
sys = tfest(data,np,nz)
sys = tfest(data,np,nz,iodelay)
sys = tfest(___,Name,Value)
sys = tfest(data,init_sys)
sys = tfest(___,opt)
sys = tfest(data,np) estimates a continuoustime transfer function, sys, using time or frequencydomain data, data, and contains np poles. The number of zeros in the sys is max(np1,0).
sys = tfest(data,np,nz) estimates a transfer function containing nz zeros.
sys = tfest(data,np,nz,iodelay) estimates a transfer function with transport delay for input/output pairs iodelay.
sys = tfest(___,Name,Value) uses additional options specified by one or more Name,Value pair arguments. All input arguments described for previous syntaxes also apply here.
sys = tfest(data,init_sys) uses the dynamic system init_sys to configure the initial parameterization of sys.
sys = tfest(___,opt) specifies the estimation behavior using the option set opt. All input arguments described for previous syntaxes also apply here.
data 
Estimation data. For time domain estimation, data is an iddata object containing the input and output signal values. Timeseries models, which are models that contain no measured inputs, cannot be estimated using tfest. Use ar, arx or armax for timeseries models instead. For frequency domain estimation, data can be one of the following:
For multiexperiment data, the sample times and intersample behavior of all the experiments must match. 
np 
Number of poles in the estimated transfer function. np is a nonnegative number. For systems that are multipleinput, or multipleoutput, or both:

nz 
Number of zeros in the estimated transfer function. nz is a nonnegative number. For systems that are multipleinput, or multipleoutput, or both:
For a continuoustime model, estimated using discretetime data, set nz <= np. 
iodelay 
Transport delay. For continuoustime systems, specify transport delays in the time unit stored in the TimeUnit property of data. For discretetime systems, specify transport delays as integers denoting delay of a multiple of the sampling period Ts. For a MIMO system with ny outputs and nu inputs, set iodelay to an nybynu array. Each entry of this array is a numerical value that represents the transport delay for the corresponding input/output pair. You can also set iodelay to a scalar value to apply the same delay to all input/output pairs. The specified values are treated as fixed delays. iodelay must contain either nonnegative numbers or NaNs. Use NaN in the iodelay matrix to denote unknown transport delays. Use [] or 0 to indicate that there is no transport delay. 
opt 
Estimation options. opt is an options set, created using tfestOptions, that specifies estimation options including:

init_sys 
Dynamic system that configures the initial parameterization of sys. If init_sys is an idtf model, tfest uses the parameters and constraints defined in init_sys as the initial guess for estimating sys. Use the Structure property of init_sys to configure initial guesses and constraints for the numerator, denominator and transport lag. To specify an initial guess for, say, the numerator of init_sys, set init_sys.Structure.num.Value to the initial guess. To specify constraints for, say, the numerator of init_sys:
You can similarly specify the initial guess and constraints for the denominator and transport lag. If init_sys is not an idtf model, the software first converts init_sys to a transfer function. tfest uses the parameters of the resulting model as the initial guess for estimation. 
Specify optional commaseparated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.
Input delay for each input channel, specified as a numeric vector. For continuoustime systems, specify input delays in the time unit stored in the TimeUnit property. For discretetime systems, specify input delays in integer multiples of the sampling period Ts. For example, InputDelay = 3 means a delay of three sampling periods.
For a system with Nu inputs, set InputDelay to an Nuby1 vector. Each entry of this vector is a numerical value that represents the input delay for the corresponding input channel.
You can also set InputDelay to a scalar value to apply the same delay to all channels.
Feedthrough for discretetime transfer function. Must be a NybyNu logical matrix. Use a scalar to specify a common value across all channels.
A discretetime model with 2 poles and 3 zeros takes the following form:
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.
sys 
Identified transfer function. sys is an idtf model that encapsulates the identified transfer function. 
Load timedomain 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 timedomain, inputoutput 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.
Load time domain system response data and use it to estimate a transfer function for the system.
load iddata2 z2; np = 2; nz = 1; sys = tfest(z2,np,nz);
z2 is an iddata object that contains time domain system response data.
np and nz specify the number of poles and zeros in the estimated transfer function, respectively.
sys is an idtf model containing the estimated transfer function.
Load time domain system response data and use it to estimate a transfer function for the system. Specify a known transport delay for the transfer function.
load iddata2 z2; np = 2; nz = 1; iodelay = 0.2; sys = tfest(z2,np,nz,iodelay);
z2 is an iddata object that contains time domain system response data.
np and nz specify the number of poles and zeros in the estimated transfer function, respectively.
iodelay specifies the transport delay for the estimated transfer function as 0.2 seconds.
sys is an idtf model containing the estimated transfer function, with ioDelay set to 0.2 seconds.
Load time domain system response data and use it to estimate a transfer function for the system. Specify an unknown transport delay for the transfer function.
load iddata2 z2; np = 2; nz = 1; iodelay = NaN; sys = tfest(z2,np,nz,iodelay);
z2 is an iddata object that contains time domain system response data.
np and nz specify the number of poles and zeros in the estimated transfer function, respectively.
iodelay specifies the transport delay for the estimated transfer function. iodelay = NaN denotes the transport delay as an unknown parameter to be estimated.
sys is an idtf model containing the estimated transfer function, whose ioDelay is estimated using data.
Load timedomain system response data.
load iddata2 z2;
z2 is an iddata object that contains time domain system response data.
Estimate a transfer function with a sample time and known transport delay
np = 2;
nz = 1;
iodelay = 2;
Ts = 0.1;
sysd = tfest(z2,np,nz,iodelay,'Ts',Ts);
By default, the model has no feedthrough.
Estimate a discretetime transfer function whose numerator polynomial has a nonzero leading coefficient.
load iddata5 z5 np = 3; nz = 1; model = tfest(z5,np,nz,'ts',z5.ts,'Feedthrough',true);
Compare two discretetime models with and without feedthrough and transport delay.
If there is a delay from the measured input to output, it can be attributed to a lack of feedthrough or to a true transport delay. For discretetime models, absence of feedthrough corresponds to a lag of 1 sample between the input and output. Estimating a model with Feedthrough = false and ioDelay = 0 thus produces a discretetime system that is equivalent to a system with Feedthrough = true and ioDelay = 1. Both systems show the same time and frequencydomain responses, for example, on step and Bode plots. However, you get different results if you reduce these models using balred or convert them to their continuoustime representation. Therefore, you should check if the observed delay should be attributed to transport delay or to a lack of feedthrough.
Estimate a discretetime model with no feedthrough.
load iddata1 z1 np = 2; nz = 2; model1 = tfest(z1, np, nz, 'Ts', z1.Ts);
model1 has a transport delay of 1 sample and its ioDelay property is 0. Its numerator polynomial begins with .
Estimate another discretetime model with feedthrough and 1 sample inputoutput delay.
model2 = tfest(z1, np, nz1, 1, 'Ts', z1.Ts, 'Feedthrough', true);
Compare the Bode response of the models.
bode(model1,model2);
The equations for model1 and model2 are equivalent, but the transport delay of model2 has been absorbed into the numerator of model1.
Convert the models to continuous time, and compare their Bode responses.
bode(d2c(model1),d2c(model2));
As the plot shows, the Bode responses of the two models do not match when you convert them to continuous time.
Estimate a 2input, 1output discretetime transfer function with a delay of 2 samples on first input and zero seconds on the second input. Both inputs have no feedthrough.
Split data into estimation and validation data sets.
load iddata7 z7 ze = z7(1:300); zv = z7(200:400);
Estimate a 2input, 1output transfer function with 2 poles and 1 zero for each inputtooutput transfer function.
Lag = [2; 0]; Ft = [false, false]; model = tfest(ze, 2, 1, 'Ts', z7.Ts, 'Feedthrough', Ft, 'InputDelay', Lag);
Choice of Feedthrough dictates whether the leading numerator coefficient is zero (no feedthrough) or not (nonzero feedthrough). Delays are expressed separately using InputDelay or ioDelay property. This example uses InputDelay to express the delays.
Validate the estimated model. Exclude the data outliers for validation.
I = 1:201; I(114:118) = [];
opt = compareOptions('Samples',I);
compare(zv, model, opt)
Identify a 15th order transfer function model from data collected by simulating a highorder system.
Load data.
load regularizationExampleData m0simdata;
Estimate an unregularized transfer function model.
m = tfest(m0simdata, 15);
Estimate a regularized transfer function model.
opt = tfestOptions; opt.Regularization.Lambda = 0.02632; mr = tfest(m0simdata, 15, opt);
Compare the model outputs with data.
compare(m0simdata, m, mr);
Identify a 15th order transfer function model by using regularized impulse response estimation
Load data.
load regularizationExampleData m0simdata;
Obtain regularized impulse response (FIR) model.
opt = impulseestOptions('RegulKernel', 'DC'); m0 = impulseest(m0simdata, 70, opt);
Convert model into a transfer function model after reducing order to 15.
m = idtf(balred(idss(m0),15));
Compare the model output with data.
compare(m0simdata, m);
Create the options set for tfest.
opt = tfestOptions('InitMethod', 'n4sid', 'Display', 'on', 'SearchMethod','lsqnonlin');
opt specifies that the initialization method as 'n4sid', and the search method as 'lsqnonlin'. It also specifies that the lossfunction values for each iteration be shown.
Load time domain system response data and use it to estimate a transfer function for the system. Specify the estimation options using opt.
load iddata2 z2; np = 2; nz = 1; iodelay = 0.2; sysc = tfest(z2,np,nz,iodelay,opt);
z2 is an iddata object that contains time domain system response data.
np and nz specify the number of poles and zeros in the estimated transfer function, respectively.
iodelay specifies the transport delay for the estimated transfer function as 0.2 seconds.
opt specifies the estimation options.
sys is an idtf model containing the estimated transfer function.
Load time domain system response data, and use it to estimate a transfer function for the system. Specify the input delay for the estimated transfer function.
load iddata2 z2; np = 2; nz = 1; input_delay = 0.2; sys = tfest(z2,np,nz,'InputDelay',input_delay)
z2 is an iddata object that contains time domain system response data.
np and nz specify the number of poles and zeros in the estimated transfer function, respectively.
input_delay specifies the input delay for the estimated transfer function as 0.2 seconds.
sys is an idtf model containing the estimated transfer function with an input delay of 0.2 seconds.
This example shows how to convert frequencyresponse data into transfer function.
This example requires a Control System Toolbox™ license.
Obtain frequency response data.
For example, use bode to obtain the magnitude and phase response data for the following system:
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]),freq); data = frd(mag.*exp(1j*phase*pi/180),freq);
Estimate a transfer function using data.
np = 3; nz = 1; sys = tfest(data,np,nz);
np and nz specify the number of poles and zeros in the estimated transfer function, respectively.
sys is an idtf model containing the estimated transfer function.
Estimate a transfer function to fit a given frequency response data (FRD) containing additional phase roll off induced by input delay.
This example requires a Control System Toolbox license.
Obtain frequency response data.
For this example, use bode to obtain the magnitude and phase response data for the following system:
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 estimated 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 estimated transfer function, respectively.
iodelay specifies an unknown transport delay for the estimated transfer function.
sys is an idtf model containing the estimated transfer function.
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.
Load time domain system response data.
load co2data;
Ts = 0.5;
data = iddata(Output_exp1,Input_exp1,Ts);
data is an iddata object and has a sample rate of 0.5 seconds.
Specify the search method as gna. Also specify the maximum search iterations and input/output offsets.
opt = tfestOptions('SearchMethod','gna'); opt.InputOffset = [170; 50]; opt.OutputOffset = mean(data.y(1:75)); opt.SearchOption.MaxIter = 50;
opt is an estimation option set that specifies the search method as gna, with a maximum of 50 iterations. opt also specifies the input offset and the output offset.
Estimate a transfer function using the measured data and the estimation option set. Specify the transport delays from the inputs to the output.
np = 3; nz = 1; iodelay = [2 5]; sys = tfest(data,np,nz,iodelay,opt);
iodelay specifies the input to output delay from the first and second inputs to the output as 2 seconds and 5 seconds, respectively.
sys is an idtf model containing the estimated transfer function.
Load time domain system response data and use it to estimate a transfer function for the system. Specify the known and unknown transport delays.
load co2data;
Ts = 0.5;
data = iddata(Output_exp1,Input_exp1,Ts);
data is an iddata object and has a sample rate of 0.5 seconds.
Specify the search method as gna. Also specify the maximum search iterations and input/output offsets.
opt = tfestOptions('Display','on','SearchMethod','gna'); opt.InputOffset = [170; 50]; opt.OutputOffset = mean(data.y(1:75)); opt.SearchOption.MaxIter = 50;
opt is an estimation option set that specifies the search method as gna, with a maximum of 50 iterations. opt also specifies the input/output offsets.
Estimate the transfer function. Specify the unknown and known transport delays.
np = 3; nz = 1; iodelay = [2 nan]; sys = tfest(data,np,nz,iodelay,opt)
iodelay specifies the transport delay from the first input to the output as 2 seconds. Using NaN specifies the transport delay from the second input to the output as unknown.
sys is an idtf model containing the estimated transfer function.
Create a transfer function model with the expected numerator and denominator structure and delay constraints.
In 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 use it to estimate a transfer function.
load co2data; Ts = 0.5; data = iddata(Output_exp1,Input_exp1,Ts); opt = tfestOptions('Display','on','SearchMethod','gna'); opt.InputOffset = [170; 50]; opt.OutputOffset = mean(data.y(1:75)); opt.SearchOption.MaxIter = 50; sys = tfest(data,init_sys,opt)
data is an iddata object and has a sample rate of 0.5 seconds.
opt is an estimation option set that specifies the search method as gna, with a maximum of 50 iterations. opt also specifies the input offset and the output offset.
sys is an idtf model containing the estimated transfer function.
Analyze the estimation result by comparison.
opt2 = compareOptions; opt2.InputOffset = opt.InputOffset; opt2.OutputOffset = opt.OutputOffset; compare(data, sys, opt2)
Estimate a multipleinput, singleoutput transfer function containing different number of poles for input/output pairs for given data.
This example requires a Control System Toolbox license.
Obtain frequency response data.
For example, use frd to frequency response data model for the following system:
Use 100 frequency points, ranging from 0.01 rad/s to 100 rad/s, to obtain the frequency response data.
G = tf({[1 2],[5]},{[1 2 4 5],[1 2 1 1 0]},0,'ioDelay',[4 .6]);
data = frd(G,logspace(2,2,100));
data is an frd object containing the continuoustime frequency response for G.
Estimate a transfer function for data.
np = [3 4]; nz = [1 0]; iodelay = [4 .6]; sys = tfest(data,np,nz,iodelay);
np specifies the number of poles in the estimated transfer function. The first element of np indicates that the transfer function from the first input to the output contains 3 poles. Similarly, the second element of np indicates that the transfer function from the second input to the output contains 4 poles.
nz specifies the number of zeros in the estimated transfer function. The first element of nz indicates that the transfer function from the first input to the output contains 1 zero. Similarly, the second element of np indicates that the transfer function from the second input to the output does not contain any zeros.
iodelay specifies the transport delay from the first input to the output as 4 seconds. The transport delay from the second input to the output is specified as 0.6 seconds.
sys is an idtf model containing the estimated transfer function.
Estimate a transfer function describing an unstable system for given data.
This example requires a Control System Toolbox license.
Obtain frequency response data.
For example, use frd to frequency response data model for the following system:
Use 100 frequency points, ranging from 0.01 rad/s to 100 rad/s, to obtain the frequency response data.
G = tf({[1 2],[5]},{[1 2 4 5],[1 2 1 1 1]}); data = frd(G,logspace(2,2,100));
data is an frd object containing the continuoustime frequency response for G.
Create estimation options set.
opt = tfestOptions('Focus','prediction');
Estimate a transfer function for data, using the options set opt.
np = [3 4]; nz = [1 0]; sys = tfest(data,np,nz,opt);
np specifies the number of poles in the estimated transfer function. The first element of np indicates that the transfer function from the first input to the output contains 3 poles. Similarly, the second element of np indicates that the transfer function from the second input to the output contains 4 poles.
nz specifies the number of zeros in the estimated transfer function. The first element of nz indicates that the transfer function from the first input to the output contains 1 zero. Similarly, the second element of np indicates that the transfer function from the second input to the output does not contain any zeros.
opt specifies the estimation options for estimating the transfer function.
sys is an idtf model containing the estimated transfer function.
tfest uses the prediction error minimization (PEM) approach to estimate transfer function coefficients. In general, the estimating algorithm performs two major tasks:
Initializing the estimable parameters.
Updating the estimable parameters.
The details of the algorithms used to perform these tasks vary depending on a variety of factors, including the sampling of the estimated model and the estimation data.
The estimation algorithm initializes the estimable parameters using the method specified by the InitMethod estimation option. The default method is the Instrument Variable (IV) method.
The StateVariable Filters (SVF) approach and the Generalized Poisson Moment Functions (GPMF) approach to continuoustime parameter estimation use prefiltered data [1] [2]. The constant in [1] and [2] corresponds to the initialization option (InitOption) field FilterTimeConstant. IV is the simplified refined IV method and is called SRIVC in [1] and [2]. This method has a prefilter that is the denominator of the current model, initialized with SVF. This prefilter is iterated up to MaxIter times, until the model change is less than Tolerance. MaxIter and Tolerance are options that you can specify using the InitOption structure. The 'n4sid' initialization option estimates a discretetime model, using the N4SID estimation algorithm, that it transforms to continuoustime using d2c.
You use tfestOptions to create the option set used to estimate a transfer function.
The initialized parameters are updated using a nonlinear leastsquares search method, specified by the SearchMethod estimation option. The objective of the search method is to minimize the weighted prediction error norm.
For discretetime data, tfest uses the same algorithm as oe to determine the numerator and denominator polynomial coefficients. In this algorithm, the initialization is performed using arx, followed by nonlinear leastsquares search based updates to minimize a weighted prediction error norm.
For continuoustime data and fixed delays, the OutputError algorithm is used. For continuoustime data and free delays, or for discretetime data, the statespace estimation algorithm is used. In this algorithm, the model coefficients are initialized using the N4SID estimation method. This initialization is followed by nonlinear leastsquares search based updates to minimize a weighted prediction error norm.
When delay values are specified as NaN, they are estimated separate from the model's numerator and denominator coefficients, using delayest. The delay values thus determined are treated as fixed values during the iterative update of the model using a nonlinear leastsquares search method. Thus, the delay values are not iteratively updated. The only exception is the estimation of continuoustime models using continuoustime data.
For an initial model, init_sys, with:
init_sys.Structure.ioDelay.Value specified as finite values
init_sys.Structure.ioDelay.Free specified as true
the transport delay values are updated during estimation only if you are using continuoustime, frequencydomain data and init_sys.Ts is zero. In all other cases, the initial delay values are left unchanged.
Estimation of delays is often a difficult problem. You should assess the presence and the value of a delay. To do so, use physical insight of the process being modeled and functions such as arxstruc, delayest, and impulseest. For an example of determining input delay, see Model Structure Selection: Determining Model Order and Input DelayModel Structure Selection: Determining Model Order and Input Delay.
[1] Garnier, H., M. Mensler, and A. Richard. "Continuoustime Model Identification From Sampled Data: Implementation Issues and Performance Evaluation" International Journal of Control, 2003, Vol. 76, Issue 13, pp 1337–1357.
[2] Ljung, L. "Experiments With Identification of ContinuousTime Models." Proceedings of the 15th IFAC Symposium on System Identification. 2009.
ar  arx  bj  greyest  idtf  oe  polyest  procest  ssest  tfestOptions