Linear grey-box model estimation


sys = greyest(data,init_sys)
sys = greyest(data,init_sys,opt)


sys = greyest(data,init_sys) estimates a linear grey-box model, sys, using time or frequency domain data, data. The dimensions of the inputs and outputs of data and init_sys, an idgrey model, must match. sys is an identified idgrey model that has the same structure as init_sys.

sys = greyest(data,init_sys,opt) estimates a linear grey-box model using the option set, opt, to configure the estimation options.

Input Arguments


Estimation data.

The dimensions of the inputs and outputs of data and init_sys must match.

For time-domain estimation, data is an iddata object containing the input and output signal values.

For frequency domain estimation, data can be one of the following:

  • Recorded frequency response data (frd or idfrd)

  • iddata object with its Domain property set to 'Frequency'


Identified linear grey-box model that configures the initial parameterization of sys.

init_sys, an idgrey model, must have the same input and output dimensions as data.


Estimation options.

opt is an option set, created using greyestOptions, which specifies options including:

  • Estimation objective

  • Initialization choice

  • Disturbance model handling

  • Numerical search method to be used in estimation

Output Arguments


Estimated linear grey-box model.

sys is an idgrey model that encapsulates the estimated linear grey-box model.


collapse all

Estimate Grey-Box Model

Estimate the parameters of a DC motor using the linear grey-box framework.

Load the measured data.

load(fullfile(matlabroot, 'toolbox', 'ident', ...
					'iddemos', 'data', 'dcmotordata'));
data = iddata(y, u, 0.1, 'Name', 'DC-motor');
data.InputName = 'Voltage';
data.InputUnit = 'V';
data.OutputName = {'Angular position', 'Angular velocity'};
data.OutputUnit = {'rad', 'rad/s'};
data.Tstart = 0;
data.TimeUnit = 's';

data is an iddata object containing the measured data for the outputs, the angular position, the angular velocity. It also contains the input, the driving voltage.

Create a grey-box model representing the system dynamics.

For the DC motor, choose the angular position (rad) and the angular velocity (rad/s) as the outputs and the driving voltage (V) as the input. Set up a linear state-space structure of the following form:

$$ \dot {x}(t) =  \left [ \matrix{0 & 1 \cr
0& -\frac{1}{\tau}\cr }\right]x(t) + \left [ \matrix{0\cr \frac{G}{\tau}\cr} \right]u(t)$$

$$ y(t) =  \left [ \matrix{1 & 0 \cr
0& 1\cr }\right]x(t).$$

$\tau$ is the time constant of the motor in seconds, and $G$ is the static gain from the input to the angular velocity in rad/(V*s) .

G = 0.25;
tau = 1;

init_sys = idgrey('motor',tau,'cd',G,0);

The governing equations in state-space form are represented in the MATLAB® file motor.m. To view the contents of this file, enter edit motor.m at the MATLAB command prompt.

$G$ is a known quantity that is provided to motor.m as an optional argument.

$\tau$ is a free estimation parameter.

init_sys is an idgrey model associated with motor.m.

Estimate $\tau$.

sys = greyest(data,init_sys);

sys is an idgrey model containing the estimated value of $\tau$.

To obtain the estimated parameter values associated with sys, use getpvec(sys).

Analyze the result.

opt = compareOptions('InitialCondition','zero');

sys provides a 98.35% fit for the angular position and an 84.42% fit for the angular velocity.

Estimate Grey-Box Model Using Regularization

Estimate the parameters of a DC motor by incorporating prior information about the parameters when using regularization constants.

The model is parameterized by static gain G and time constant $\tau$. From prior knowledge, it is known that G is about 4 and $\tau$ is about 1. Also, you have more confidence in the value of $\tau$ than G and would like to guide the estimation to remain close to the initial guess.

Load estimation data.

load regularizationExampleData.mat motorData

The data contains measurements of motor's angular position and velocity at given input voltages.

Create an idgrey model for DC motor dynamics. Use the function DCMotorODE that represents the structure of the grey-box model.

mi = idgrey(@DCMotorODE,{'G', 4; 'Tau', 1},'cd',{}, 0);
mi = setpar(mi, 'label', 'default');

If you want to view the DCMotorODE function, type:

type DCMotorODE.m
function [A,B,C,D] = DCMotorODE(G,Tau,Ts)
%DCMOTORODE ODE file representing the dynamics of a DC motor parameterized
%by gain G and time constant Tau.
%   [A,B,C,D,K,X0] = DCMOTORODE(G,Tau,Ts) returns the state space matrices
%   of the DC-motor with time-constant Tau and static gain G. The sample
%   time is Ts.
%   This file returns continuous-time representation if input argument Ts
%   is zero. If Ts>0, a discrete-time representation is returned.

%   Copyright 2013 The MathWorks, Inc.

A = [0 1;0 -1/Tau];
B = [0; G/Tau];
C = eye(2);
D = [0;0];
if Ts>0 % Sample the model with sample time Ts
   s = expm([[A B]*Ts; zeros(1,3)]);
   A = s(1:2,1:2);
   B = s(1:2,3);

Specify regularization options Lambda.

opt = greyestOptions;
opt.Regularization.Lambda = 100;

Specify regularization options R.

opt.Regularization.R = [1, 1000];

You specify more weighting on the second parameter because you have more confidence in the value of $\tau$ than G.

Specify the initial values of the parameters as regularization option $\theta$*.

opt.Regularization.Nominal = 'model';

Estimate the regularized grey-box model.

sys = greyest(motorData, mi, opt);

Related Examples

Was this topic helpful?