Estimate initial states of nonlinear grey-box model from data


X0 = findstates(NLSYS,DATA);
[X0,ESTINFO] = findstates(NLSYS,DATA);
[X0,ESTINFO] = findstates(NLSYS,DATA,X0INIT);


X0 = findstates(NLSYS,DATA); estimates the initial states of an idnlgrey model from given data. For more information about the states of idnlgrey models, see Definition of idnlgrey States.

[X0,ESTINFO] = findstates(NLSYS,DATA); returns basic information about the estimation.

[X0,ESTINFO] = findstates(NLSYS,DATA,X0INIT); specifies an initial guess for X0.

Input Arguments

  • NLSYS: idnlgrey model whose output is to be predicted.

  • DATA: Input/output data DATA = [Y U], where U and Y are the following:

    • U: Input data that can be given either as an iddata object or as a matrix U = [U1 U2 ...Um], where the kth column vector is input Uk

    • Y: Either an iddata object or a matrix of outputs (with as many columns as there are outputs).

      Note:   For time-continuous idnlgrey models, DATA passed as a matrix will cause the data sample interval Ts to be assumed to be equal to 1.

  • X0INIT: Initial state strategy to use:

    • 'zero': Use zero initial state and estimate all states (NLSYS.InitialStates.Fixed is thus ignored). Notice that all states are estimated, whereas they are fixed in predict.

    • 'estimate': NLSYS.InitialStates determines the values of the states, but all initial states are estimated (NLSYS.InitialStates.Fixed is thus ignored).

    • 'model': (Default) NLSYS.InitialStates determines the values of the initial states, which initial states to estimate, as well as their maximum and minimum values.

    • vector/matrix: Column vector of appropriate length to be used as an initial guess for initial states. For multiple experiment DATA, X0INIT may be a matrix whose columns give different initial states for each experiment. With this option, all initial states are estimated (and not fixed as in predict) (NLSYS.InitialStates.Fixed is thus ignored).

    • struct array: Nx-by-1 structure array with fields:

      • Name: Name of the state (a string).

      • Unit: Unit of the state (a string).

      • Value: Value of the states (a finite real 1-by-Ne vector, where Ne is the number of experiments).

      • Minimum: Minimum values of the states (a real 1-by-Ne vector or a real scalar, in which case all initial states have the same minimum value).

      • Maximum: Maximum values of the states (a real 1-by-Ne vector or a real scalar, in which case all initial states have the same maximum value).

      • Fixed: Boolean 1-by-Ne vector, or a scalar Boolean (applicable for all states) specifying whether the initial state is fixed or not.

Output Arguments

  • X0: Matrix containing the initial states. In the single experiment case it is a column vector of length Nx. For multi-experiment data, X0 is a matrix with as many columns as there are experiments.

  • ESTINFO: Structure or Ne-by-1 structure array containing basic information about the estimation result (some of the fields normally stored in NLSYS.EstimationInfo). For multi-experiment data, ESTINFO is an Ne-by-1 structure array with elements providing initial state estimation information related to each experiment.


Estimating Individual Initial States Selectively

In this example you estimate the initial states of a model selectively, fixing the first state and allowing the second state of the model to be estimated. First you create a model from sample data and set the Fixed property of the model such that the second state is free and the first is fixed.

  1. Specify the file describing the model structure, the model orders, and model parameters.

    % Specify the file describing the model structure:
    FileName = 'dcmotor_m'; 
    % Specify the model orders [ny nu nx]
    Order = [2 1 2];
    % Specify the model parameters
    % (see idnlgreydemo1 for more information)
    Parameters = [0.24365; 0.24964]; 
  2. Estimate the model parameters and set the model properties:

    nlgr = idnlgrey(FileName, Order, Parameters);
    set(nlgr, 'InputName', 'Voltage','OutputName', ...
    		{'Angular position', 'Angular velocity'});
  3. Free the second state while keeping the first one fixed.

    setinit(nlgr,'Fixed',{1 0});
  4. Load the estimation data.

    z = iddata(y,u,0.1,'Name','DC-motor',...
         'InputName', 'Voltage', 'OutputName',...
         {'Angular position','Angular velocity'});
  5. Estimate the free states of the model.

    [X0,EstInfo] = findstates(nlgr,z)

Estimating Initial States Starting from States Stored in Model

This example shows how you can estimate all of the initial states, starting from the initial state 0, then from the initial states stored in the model nlgr, and finally using a numerical initial states vector as the initial guess.

  1. Estimate all the initial states starting from 0.

    X0 = findstates(nlgr,z,'zero');
  2. Estimate the free initial states specified by nlgr, starting from the initial state stored in nlgr.

    X0 = findstates(nlgr, z, 'mod'); 
  3. Estimate all the initial states, starting from an initial state vector that you specify.

    nlgr.Algorithm.Display = 'full';
    % Starting from an initial state vector [10;10]
    X0 = findstates(nlgr,z,[10;10]) 

Advanced Use of findstates(idnlgrey)

The following example shows advanced use of findstates. Here you estimate states for multi-experiment data, such that the states of model nlgr are estimated separately for each experiment. After creating a 3-experiment data set z3, you estimate individual initial states separately.

  1. Create a three-experiment data set.

    z3 = merge(z, z, z); % 3-experiment data
  2. Fix some initial states and only estimate the free initial states starting of with the initial state in nlgr. This means that both elements of state vector 1 will be estimated, that no state of the second state vector will be estimated, and that only the first state of state vector 3 is estimated.

    % prepare model for 3-experiment data
    nlgr = pem(z3, nlgr, 'Display', 'off');
  3. Specify which initial states to fix, and set the Display property of Algorithm to 'full'.

    nlgr.InitialStates(1).Fixed = [true false true];
    nlgr.InitialStates(2).Fixed = [true false false];
    nlgr.Algorithm.Display = 'full';
  4. Estimate the initial states and obtain information about the estimation.

    [X0, EstInfo] = findstates(nlgr, z3);
Was this topic helpful?