MATLAB Examples

# Estimate Structured Continuous-Time State-Space Models

This example shows how to estimate the unknown parameters of a continuous-time model.

In this example, you estimate in the following continuous-time model:

This equation represents an electrical motor, where is the angular position of the motor shaft, and is the angular velocity. The parameter is the inverse time constant of the motor, and is the static gain from the input to the angular velocity.

The motor is at rest at t=0 , but its angular position is unknown. Suppose that the approximate nominal values of the unknown parameters are and .

The variance of the errors in the position measurement is 0.01 , and the variance in the angular velocity measurements is 0.1 . For more information about this example, see the section on state-space models in System 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:

Construct the parameter matrices and initialize the parameter values using the nominal parameter values.

A = [0 1;0 -1]; B = [0;0.25]; C = eye(2); D = [0;0]; K = zeros(2,2); x0 = [0;0]; 

The matrices correspond to continuous-time representation. However, to be consistent with the idss object property name, this example uses A, B, and C instead of F, G, and H.

Construct the continuous-time state-space model object.

m = idss(A,B,C,D,K,'Ts',0); 

Specify the parameter values in the structure matrices that you do not want to estimate.

S = m.Structure; S.A.Free(1,:) = false; S.A.Free(2,1) = false; S.B.Free(1) = false; S.C.Free = false; S.D.Free = false; S.K.Free = false; m.Structure = S; m.NoiseVariance = [0.01 0; 0 0.1]; 

The initial state is partially unknown. Use the InitialState option of the ssestOptions option set to configure the estimation behavior of X0.

opt = ssestOptions; opt.InitialState = idpar(x0); opt.InitialState.Free(2) = false; 

Estimate the model structure.

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

The iterative search for a minimum is initialized by the parameters in the nominal model m . The continuous-time model is sampled using the same sample time as the data during estimation.

Simulate this system using the sample time T=0.1 for input u and the noise realization e.

e = randn(300,2); u1 = idinput(300); simdat = iddata([],u1,'Ts',0.1); simopt = simOptions('AddNoise',true,'NoiseData',e); y1 = sim(m,simdat,simopt); 

The continuous system is sampled using Ts=0.1 for simulation purposes. The noise sequence is scaled according to the matrix m.NoiseVariance .

If you discover that the motor was not initially at rest, you can estimate by setting the second element of the InitialState parameter to be free.

opt.InitialState.Free(2) = true; m_new = ssest(z,m,opt);