findstates(idnlgrey)

Estimate initial states of nonlinear Grey-Box model from data

Syntax

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

Description

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

Input

Examples

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, model orders and model parameters.

    % File describing the model structure.
    FileName      = 'dcmotor_m'; 
    Order         = [2 1 2]; % Model orders [ny nu nx].
    
    % Model's parameters (see idnlgreydemo1 for information)
    Parameters    = [0.24365; 0.24964]; 
    
  2. Estimate the idnlgrey model 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.

    load(fullfile(matlabroot, 'toolbox', 'ident', ...
    					'iddemos', 'data', 'dcmotordata'));
    z = iddata(y, u, 0.1, 'Name', 'DC-motor','InputName', 'Voltage',...
        'OutputName', {'Angular position', 'Angular velocity'});
    
  5. Estimate the free states of the model.

    % Default calling syntax. The same as with 
    % 'model' as third argument.
    [X0, EstInfo] = findstates(nlgr, z)
    

    This command computes:

    X0 =
                0
          -0.0179
    EstInfo = 
            Method: 'Solver: ode45; Search: lsqnonlin'
          DataName: 'DC-motor, Exp1'
           WhyStop: 'Near (local) minimum, (norm(g) < tol)'
        Iterations: 1
    

Estimating Initial States Starting from States Stored in Model

This example shows how you can also estimate all initial states, starting from an initial state of 0, then again from the initial states stored in nlgr.

  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. The fixed/free setting of initial states as specified in nlgr are honored.

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

    nlgr.Algorithm.Trace = '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, 'Trace', 'off');
    
  3. Specify which initial states to fix, and set the Trace property of Algorithm to 'full'.

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

    [X0, EstInfo] = findstates(nlgr, z3);

See Also

findstates(idnlarx) 
findstates(idnlhw) 
predict 
sim 

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS