Skip to Main Content Skip to Search
Product Documentation

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 Arguments

Output Arguments

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 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.

    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.

    [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);

See Also

findstates(idnlarx) | findstates(idnlhw) | predict | sim

  


Free Control Systems Interactive Kit

Learn more about resources for designing, testing, and implementing control systems.

Get free kit

Trials Available

Try the latest control systems products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS