# idgrey

Linear ODE (grey-box model) with identifiable parameters

## Description

An `idgrey`

model represents a linear system as a continuous-time
or discrete-time state-space model with identifiable (estimable) coefficients. Use an
`idgrey`

model when you want to capture complex relationships, constraints,
and prior knowledge that structured state-space (`idss`

) models cannot encapsulate. To create an `idgrey`

model, you
must know explicitly the system of equations (ordinary differential or difference equations)
that govern the system dynamics.

An `idgrey`

model allows you to incorporate conditions such as the following:

Parameter constraints that the

`idss`

/`ssest`

framework cannot handle, such as linear or equality constraints on parameters, or prior knowledge about the variance of the states, inputs, outputs, or any combination of the three, that you want to include as known informationA linear model of an arbitrary form, such as a transfer function or polynomial model, with parameter constraints such as a known DC gain, limits on pole locations, a shared denominator across multiple inputs, or nonzero input/output delays in MIMO models

Differential or difference equations with known and unknown coefficients

In these and similar cases, you can create an ODE (ordinary differential or difference
equation) function in MATLAB^{®} that implements a state-space realization of the linear model and that specifies
constraints and prior knowledge.

A simple example of creating an ODE for `idgrey`

uses the following
equations to describe motor dynamics.

$$\begin{array}{l}\dot{x}(t)=\left[\begin{array}{cc}0& 1\\ 0& -\frac{1}{\tau}\end{array}\right]x(t)+\left[\begin{array}{c}0\\ \frac{G}{\tau}\end{array}\right]u(t)\\ y(t)=\left[\begin{array}{cc}1& 0\\ 0& 1\end{array}\right]x(t)\end{array}$$

In these equations, *τ* is the single estimable parameter and
*G* represents the known static gain.

These equations fit the state-space form:

$$\begin{array}{l}\dot{x}(t)=Ax(t)+Bu(t)\\ y(t)=Cx(t)\end{array}$$

For this case, both the *A* and *B* matrices contain the
estimable parameter *τ*, and *B* also includes the known
gain *G*. You can write a MATLAB function that accepts *τ* and *G* as input
arguments and returns the state-space matrices *A*, *B*, and
*C* as its output arguments. For example, you can code a function
`motorFcn`

as
follows.

function [A,B,C] = motorFcn(tau,G) % ODE function for computing state-space matrices as functions of parameters A = [0 1; 0 -1/tau]; B = [0; G/tau]; C = eye(2);

After creating a function such as `motorFcn`

, create an
`idgrey`

model by specifying that function as the value of its
`odefun`

input argument, as the following command
shows.

`sys = idgrey(@motorFcn,tau0,'c',G)`

`tau0`

is the initial guess for the parameter *τ*and

`G`

specifies the fixed constant. Additionally, `'c'`

indicates to `idgrey`

that `odefun`

returns matrices
corresponding to a continuous-time system. For more information, see
`function_type`

.
For an executable example that creates an `idgrey`

model from these motor
dynamics equations, see Create Grey-Box Model with Estimable Parameters.

More generally, the following equations describe state-space forms for continuous-time and discrete-time systems.

A state-space model of a system with input vector *u*, output vector
*y*, and disturbance *e*, takes the following form in
continuous time:

$$\begin{array}{l}\dot{x}(t)=Ax(t)+Bu(t)+Ke(t)\\ y(t)=Cx(t)+Du(t)+e(t)\\ x(0)=x0\end{array}$$

In discrete time, the state-space model takes the form:

$$\begin{array}{l}x[k+1]=Ax[k]+Bu[k]+Ke[k]\\ y[k]=Cx[k]+Du[k]+e[k]\\ x[1]=x0\end{array}$$

Your MATLAB ODE function incorporates the user-defined parameters into the
*A*, *B*, *C*, and *D*
matrices that the function returns. The associated `idgrey`

model references
this function, and the estimation functions `greyest`

and `pem`

use these matrix definitions when estimating
the parameters.

For more information on creating an ODE function for `idgrey`

, see
Estimate Linear Grey-Box Models.

## Creation

Create an `idgrey`

model using the `idgrey`

command. To
do so, write a MATLAB function that returns the *A*, *B*,
*C*, and *D* matrices for given values of the estimable
parameters and sample time. You can pass additional input arguments, such as a time constant
or gain, that are not parameters but that the ODE uses in the expressions for the output
arguments.

In addition to the *A*, *B*, *C*, and
*D* matrices, your MATLAB function can return the *K* matrix if you want the
*K* values to be functions of your input parameters. Your function can also
return the initial state vector *x0*. However, the alternative and
recommended approach for parameterizing *x0* is to use the
`InitialState`

estimation option of `greyestOptions`

.

Note that you can write your ODE function to represent either the continuous time dynamics
or the discrete-time dynamics regardless of the nature of the `idgrey`

model
itself. For example, you can specify a discrete-time `idgrey`

model
(`sys.Ts>0`

) that uses a continuous-time parameterization of the ODE
function. Similarly, you can specify a discrete-time parameterization of the ODE function and
use it with a continuous-time idgrey model (`sys.Ts=0`

). The
`idgrey`

input argument `fcn_type`

informs
the idgrey model what type of parameterization the ODE function uses. For more information,
see Estimate Linear Grey-Box Models.

Use the estimating functions `pem`

or `greyest`

to obtain estimated values for the unknown parameters of an
`idgrey`

model. Unlike other estimation functions such as `ssest`

, which can create a new model object, `greyest`

can estimate parameters only for an `idgrey`

model that
already exists and is specified as an input argument. You can access estimated parameters
using `sys.Structures.Parameters`

, where `sys`

is an
`idgrey`

model.

You can convert an `idgrey`

model into other dynamic systems, such as
`idpoly`

, `idss`

, `tf`

, or
`ss`

. You cannot
convert a dynamic system into an `idgrey`

model.

### Syntax

### Description

creates a linear grey-box model `sys`

= idgrey(`odefun`

,`parameters`

,`fcn_type`

)`sys`

with identifiable parameters.
`odefun`

specifies the user-defined function that relates the model
parameters `parameters`

to their state-space representation.
`fcn_type`

specifies whether the model is parameterized in
continuous-time, discrete-time, or both.

specifies additional arguments `sys`

= idgrey(`odefun`

,`parameters`

,`fcn_type`

,`extra_args`

)`extra_args`

that
`odefun`

requires.

specifies the sample time `sys`

= idgrey(`odefun`

,`parameters`

,`fcn_type`

,`extra_args`

,Ts)`Ts`

.

incorporates additional options specified by one or more name-value arguments.`sys`

= idgrey(`odefun`

,`parameters`

,`fcn_type`

,`extra_args`

,`Ts`

,`Name,Value`

)

### Input Arguments

## Properties

## Object Functions

For information about functions that are applicable to an `idgrey`

object,
see Linear Grey-Box Models.

## Examples

**Introduced before R2006a**