Asked by Alex
on 20 Sep 2012

Hello!

I'm using ssest function to estimate a state-space model of one dimensional signal. When I use ssest(y,2) I get a state-space model. However, I'd like to specify some free parameters in this state-space form:

A = [1 0;0 1]; B = [0.5; 0.5]; C = [1 1]; D = [0.1];

I package this into a model object idss(A,B,C,D) and specify the free parameters to be estimated as in this demo http://www.mathworks.com/products/sysid/examples.html?file=/products/demos/shipping/ident/iddemo7.html, but when I use ssest an error appears saying that "the number of inputs and outputs of the model must match...". So I wrote the state-space model adding some white noise inputs and zero outputs in order to match the dimensions but I got a fit to estimation data of -891.8%

Can anyone give me some guidance about the form to write this state-space model in order to apply ssest function specifying free parameters?

Do I have to use state-space models with specific dimensions? It means that I can't use a state-space model as above although it's dimensionally correct?

Thanks in advance!

Answer by Rajiv Singh
on 21 Sep 2012

Hi Alex,

Could you post some more details? When you originally created the model object (idss(A,B,C,D)), what were the sizes of the matrices? If you are fitting a model to a single signal, B must be nx-by-0, C must be 1-by-nx, and D must be 1-by-0 matrix. You probably would need a K matrix of size nx-by-1 defining the initial value of disturbance matrix K (could be NaNs if you do not have an initial guess), so you actually create idss(A,B,C,D,K). Note that when you fit a signal, it is treated as a time series (a process driven by white noise):

dx/dt = A x + Ke

y = Cx + e

This is conceptually similar to the single-input, single-output model, if you think of e(t) as input u (t). Then K (times square root of noise variance) represents the "B" matrix and D = 1 of the standard state-space form. In fact, you can use "noise2meas" command to convert the time series model into a more familiar input-output model.

Direct estimation: If you want to fit a state-space model directly (that is, no intermediate creation of a model), you can use the syntax ssest(y,2) just the way you originally tried. For more control over data properties, you should actually do:

% also specify sample time and start time

data iddata(y, [], Ts, 'tstart', 0);

model = ssest(data, 2);

iomodel = noise2meas(model);

If that did not work for you, you must post some reproduction steps so that I can investigate it more thoroughly.

Alex
on 25 Sep 2012

I did as you explained, so I could put all the constrains (free parameters). However, the fit to estimation data is around -58% most of the time. This is the new representation of the model:

A = [1 0; 0 1];

B = [0.5 0 0; 0 0.5 0];

C = [1 1];

D = [0 0 0.1];

K = 0;

I suppose this because it is working with

dx/dt = A x(t) + B u(t)

y(t) = C x(t) + D u(t) + e(t)

and it should be in this way

dx/dt = A x(t) + B u(t)

y(t) = C x(t) + D u(t)

I also wrote the model in a different way, a model with three outputs having two of them as zero, but the fit to estimation data was around 200%. Should I write the model in a different form? Is there a different way to compute A(1,1),A(2,2),B(1,1) and D(1,3) having the time series y?

Thank you for your help.

Rajiv Singh
on 26 Sep 2012

Hi Alex,

Perhaps we should discuss what you are trying to achieve. You have a time series y that you want to model. A time series model usually takes the form y = G e, that is, a white noise filter. The job of G is then to predict the value of time series N steps into future given its own past measured history. It is not a "simulation" model - N can't be arbitrarily large. For this model, you should therefore evaluate its power for small horizon predictions. If you are using COMPARE function to generate the output, use Horizon = 1 or 2 for example.

You say that you need 3 sources of noise in your model. What are they? What is the underlying equation? Are you in some fashion working with a Kalman filter representation with distinct process and sensor noise sources? If so, IDSS cannot handle such forms directly. You will need to use IDGREY models (which, btw, would also let you prescribe arbitrary parameter constraints). In particular see this example:

Rajiv

Alex
on 26 Sep 2012

Hi Rajiv,

This is what I'm trying to achieve: I have a time series y that can be modeled in this way "there are not inputs"

x(k+1) = A x(k) + w

y(k) = C x(k+1) + e

where w and e are independent white-noise terms with covariance matrices R1 and R2, respectively. As you mentioned it seems to be like a kalman filter representation. There are also free and fixed parameters, so I apply constrains as explained above.

Following the example (with IDGREY) I implemented the model having y and one input white noise:

A = [par1 0;0 1];

B = [0 ; 0];

C = [1 1];

D = [0];

R1 = [par2 0; 0 par3];

R2 = aux

However KF does not converges. I will check if it works with a different state-space representation.

Thanks!

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## Stuart McGarrity (view profile)

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/48655-ssest-function-identification-toolbox#comment_603398

Sign in to comment.