| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → System Identification Toolbox |
| Contents | Index |
| Learn more about System Identification Toolbox |
m = idgrey(MfileName,ParameterVector,CDmfile) m = idgrey(MfileName,ParameterVector,CDmfile,FileArgument,Ts,... 'Property1',Value1,...,'PropertyN',ValueN)
The function idgrey is used to create arbitrarily parameterized state-space models as idgrey objects.
MfileName is the name of an M-file that defines how the state-space matrices depend on the parameters to be estimated. The format of this M-file is given by
[A,B,C,D,K,X0] = mymfile(pars,Tsm,Auxarg)
and is further discussed below.
ParameterVector is a column vector of the nominal/initial parameters. Its length must be equal to the number of free parameters in the model (that is, the argument pars in the example below).
The argument CDmfile describes how the user-written M-file handles continuous and discrete-time models. It takes the following values:
CDmfile = 'cd': The M-file returns the continuous-time state-space matrices when called with the argument Tsm = 0. When called with a value Tsm > 0, the M-file returns the discrete-time state-space matrices, obtained by sampling the continuous-time system with sampling interval Tsm. The M-file must consequently in this case include the sampling procedure.
CDmfile = 'c'. The M-file always returns the continuous-time state-space matrices, no matter the value of Tsm. In this case the toolbox's estimation routines will provide the sampling when you are fitting the model to discrete-time data.
CDmfile = 'd'. The M-file always returns discrete-time state-space matrices that may or may not depend on Tsm.
The argument FileArgument corresponds to the auxiliary argument Auxarg in the user-written M-file. It can be used to handle several variants of the model structure, without having to edit the M-file. If it is not used, enter FileArgument = []. (Default.)
Ts denotes the sampling interval of the model. Its default value is Ts = 0, that is, a continuous-time model.
The idgrey object is a child of idmodel. Therefore any idmodel properties can be set as property name/property value pairs in the idgrey command. They can also be set by the command set, or by subassignment, as in
m.InputName = {'speed','voltage'}
m.FileArgument = 0.23
There are also two properties, DisturbanceModel and InitialState, that can be used to affect the parameterizations of K and X0, thus overriding the outputs from the M-file.
MfileName: Name of the user-written M-file.
CDmfile: How this file handles continuous and discrete-time models depending on its second argument, T.
CDmfile = 'cd' means that the M-file returns the continuous-time state-space model matrices when the argument T = 0, and the discrete-time model, obtained by sampling with sampling interval T, when T > 0.
CDmfile = 'c' means that the M-file always returns continuous-time model matrices, no matter the value of T.
CDmfile = 'd' means that the M-file always returns discrete-time model matrices that may or may not depend on the value of T.
FileArgument: Possible extra input arguments to the user-written M-file.
DisturbanceModel: Affects the parameterization of the K matrix. It can assume the following values:
'Model': This is the default. It means that the K matrix obtained from the user-written M-file is used.
'Estimate': The K matrix is treated as unknown and all its elements are estimated as free parameters.
'Fixed': The K matrix is fixed to a given value.
'None': The K matrix is fixed to zero, thus producing an output-error model.
Note that in the three last cases the output K from the user-written M-file is ignored. The estimated/fixed value is stored internally and does not change when the model is sampled, resampled, or converted to continuous time. Note also that this estimated value is tailored only to the sampling interval of the data.
InitialState: Affects the parameterization of the X0 vector. It can assume the following values:
'Model': This is the default. It means that the X0 vector is obtained from the user-written M-file.
'Estimate': The X0 matrix is treated as unknown and all its elements are estimated as free parameters.
'Fixed': The X0 vector is fixed to a given value.
'Backcast': The X0 vector is estimated using a backcast operation analogous to the idss case.
'Auto': Makes a data-dependent choice among 'Estimate', 'Backcast', and 'Model'.
A, B, C, D, K, and X0: The state-space matrices. For idgrey models, only 'K' and 'X0' can be set; the others can only be retrieved. The set 'K' and 'X0' are relevant only when DisturbanceModel/InitialState are Estimate or Fixed.
dA, dB, dC, dD, dK, and dX0: The estimated standard deviations of the state-space matrices. These cannot be set, only retrieved.
In addition, any idgrey object also has all the properties of idmodel. See Algorithm Properties and the reference page for idmodel.
Note that you can set or retrieve all properties using either the set and get commands or subscripts. Autofill applies to all properties and values, and they are case insensitive.
m.fi = 10; set(m,'search','gn') p = roots(m.a)
For a complete list of property values, use get(m). To see possible value assignments, use set(m).
The model structure corresponds to the general linear state-space structure

Here
is the time derivative
for
a continuous-time model and
for a discrete-time model.
The matrices in this time-discrete model can be parameterized
in an arbitrary way by the vector
. Write the format for the M-file
as follows:
[A,B,C,D,K,x0] = mymfile(pars,T,Auxarg)
Here the vector pars contains the parameters
,
and the output arguments A, B, C, D, K,
and x0 are the matrices in the model description
that correspond to this value of the parameters and this value of
the sampling interval T.
T is the sampling interval, and Auxarg is any variable of auxiliary quantities with which you want to work. (In that way you can change certain constants and other aspects in the model structure without having to edit the M-file.) Note that the two arguments T and Auxarg must be included in the function head of the M-file, even if they are not used within the M-file.
A comment about CDmfile: If a continuous-time model is sought, it is easiest to let the M-file deliver just the continuous-time model, that is, have CDmfile = 'c' and rely upon the toolbox's routines for the proper sampling. Similarly, if the underlying parameterization is indeed discrete time, it is natural to deliver the discrete-time model matrices and let CDmfile = 'd'. If the underlying parameterization is continuous, but you prefer for some reason to do your own sampling inside the M-file in accordance with the value of T, then let your M-file deliver the continuous-time model when called with T = 0, that is, the alternative CMmfile = 'cd'. This avoids sampling and then transforming back (using d2c) to find the continuous-time model.
The states of an idgrey model are defined explicitly by the user in the M-file or MEX-file (as specified in MfileName property) storing the model structure. The concept of states is useful for functions such as sim, predict, compare and findstates.
In this example, you use the M-file mynoise given in Example – Estimating a Discrete-Time Grey-Box Model with Parameterized Disturbance to obtain a physical parameterization of the Kalman gain. You estimate the unknown parameters of this model using the estimation data z.
mn = idgrey('mynoise',[0.1,-2,1,3,0.2]','d',1)
m = pem(z,mn)
![]() | idfrd | idinput | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |