Main Content

Estimate Linear Grey-Box Models

Specifying the Linear Grey-Box Model Structure

You can estimate linear discrete-time and continuous-time grey-box models for arbitrary ordinary differential or difference equations using single-output and multiple-output time-domain data, or time-series data (output-only).

You must represent your system equations in state-space form.State-space modelsuse state variablesx(t)to describe a system as a set of first-order differential equations, rather than by one or morenth-order differential equations.

The first step in grey-box modeling is to write a function that returns state-space matrices as a function of user-defined parameters and information about the model.

Use the following format to implement the linear grey-box model in the file:

[A,B,C,D] = myfunc(par1,par2,...,parN,Ts,aux1,aux2,...)

where the output arguments are the state-space matrices andmyfuncis the name of the file.par1,par2,...,parNare theNparameters of the model. Each entry may be a scalar, vector or matrix.Tsis the sample time.aux1,aux2,...are the optional input arguments thatmyfuncuses to compute the state-space matrices in addition to the parameters and sample time.auxcontains auxiliary variables in your system. You use auxiliary variables to vary system parameters at the input to the function, and avoid editing the file.

You can write the contents ofmyfuncto parameterize either a continuous-time, or a discrete-time state-space model, or both. When you create the linear grey-box model usingmyfunc, you can specify the nature of the output arguments ofmyfunc. The continuous-time state-space model has the form:

在连续s-time, the state-space description has the following form:

x ˙ ( t ) = A x ( t ) + B u ( t ) + K e ( t ) y ( t ) = C x ( t ) + D u ( t ) + e ( t ) x ( 0 ) = x 0

where,A,B,CandDare matrices that are parameterized by the parameterspar1,par2,...,parN. The noise matrixKand initial state vector,x0, are not parameterized bymyfunc. In some applications, you may want to expressKandx0as quantities that are parameterized by chosen parameters, just as theA,B,CandDmatrices. To handle such cases, you can write the ODE file,myfunc, to returnKandx0as additional output arguments:

[A,B,C,D,K,x0] = myfunc(par1,par2,...,parN,Ts,aux1,aux2,...)
Kandx0are thus treated in the same way as theA,B,CandDmatrices. They are all functions of the parameterspar1,par2,...,parN. To configure the handling of initial states,x0, and the disturbance component,K, during estimation, use thegreyestOptionsoption set.

In discrete-time, the state-space description has a similar form:

x ( k + 1 ) = A x ( k ) + B u ( k ) + K e ( t ) y ( k ) = C x ( k ) + D u ( k ) + e ( t ) x ( 0 ) = x 0

where,A,B,CandDare now the discrete-time matrices that are parameterized by the parameterspar1,par2,...,parN.Kandx0are not directly parameterized, but can be estimated if required by configuring the corresponding estimation options.

After creating the function or MEX-file with your model structure, you must define anidgreymodel object.

Create Function to Represent a Grey-Box Model

This example shows how to represent the structure of the following continuous-time model:

$$\begin{array}{l}
\dot x(t) = \left[ {\begin{array}{*{20}{c}}
0&1\\
0&{{\theta _1}}
\end{array}} \right]x(t) + \left[ {\begin{array}{*{20}{c}}
0\\
{{\theta _2}}
\end{array}} \right]u(t)\\
y(t) = \left[ {\begin{array}{*{20}{c}}
1&0\\
0&1
\end{array}} \right]x(t) + e(t)\\
x(0) = \left[ {\begin{array}{*{20}{c}}
{{\theta _3}}\\
0
\end{array}} \right]
\end{array}$$

This equation represents an electrical motor, where${y_1}(t) = {x_1}(t)$is the angular position of the motor shaft, and${y_2}(t) = {x_2}(t)$is the angular velocity. The parameter$- {\theta _1}$is the inverse time constant of the motor, and$- {{\theta _2}}/{{\theta _1}}$is the static gain from the input to the angular velocity.

The motor is at rest att= 0, but its angular position${\theta _3}$是未知的。假设approximate nominal values of the unknown parameters are${\theta _1} = - 1$,${\theta _2} = 0.25$and${\theta _3} = 0$. For more information about this example, see the section on state-space models inSystem Identification: Theory for the User, Second Edition, by Lennart Ljung, Prentice Hall PTR, 1999.

The continuous-time state-space model structure is defined by the following equation:

$$\begin{array}{l}
\dot x(t) = Fx(t) + Gu(t) + \tilde Kw(t)\\
y(t) = Hx(t) + Du(t) + w(t)\\
x(0) = x0
\end{array}$$

If you want to estimate the same model using a structured state-space representation, seeEstimate Structured Continuous-Time State-Space Models.

准备这个模型估算:

  • Create the following file to represent the model structure in this example:

function[A,B,C,D,K,x0] = myfunc(par,T) A = [0 1; 0 par(1)]; B = [0;par(2)]; C = eye(2); D = zeros(2,1); K = zeros(2,2); x0 = [par(3);0];

Save the file such that it is in the MATLAB® search path.

  • Use the following syntax to define anidgreymodel object based on themyfuncfile:

par = [-1; 0.25; 0]; aux = {}; T = 0; m = idgrey('myfunc',par,'c',aux,T);

whereparrepresents a vector of all the user-defined parameters and contains their nominal (initial) values. In this example, all the scalar-valued parameters are grouped in theparvector. The scalar-valued parameters could also have been treated as independent input arguments to the ODE functionmyfunc.'c'specifies that the underlying parameterization is in continuous time.auxrepresents optional arguments. Asmyfuncdoes not have any optional arguments, useaux = {}.Tspecifies the sample time;T = 0indicates a continuous-time model.

Load the estimation data.

load(fullfile(matlabroot,'toolbox','ident','iddemos','data','dcmotordata')); data = iddata(y,u,0.1);

Usegreyestto estimate the grey-box parameter values:

m_est = greyest(data,m);

wheredatais the estimation data andmis an estimation initializationidgreymodel.m_estis the estimatedidgreymodel.

See Also

|

Related Topics