Home > mpt > @mptctrl > sim.m

sim

PURPOSE ^

SIM Simulates a given controller

SYNOPSIS ^

function [X,U,Y,cost,feasible]=sim(ctrl, arg2, arg3, arg4, arg5)

DESCRIPTION ^

SIM Simulates a given controller

 ---------------------------------------------------------------------------
 DESCRIPTION
 ---------------------------------------------------------------------------
 Once initial conditions x0 are known, it is possible to simulate a given
 controller in closed-loop by running

       sim(ctrl, x0)

 Here the simulation will start from a given state "x0" and will terminate once
 a given control objective is reached (usually when the origin is reached).

 Additionally, you can specify for how many steps you want to perform the
 simulation:

       sim(ctrl, x0, N)

 Additional options can be provided as well:

       sim(ctrl, x0, N, Options)

 Hint: set N=[] in the above command if you want to specify Options but do not
 want to specify number of simulation steps.

 You can also specify your own dynamical system to use for simulations. In such
 case control actions obtained by a given controller can be applied to a
 different system than that which was used for computing the controller:

       sim(ctrl, system, x0, N, Options)

 Note that the "N" and "Options" arguments are optional. You can specify your
 own dynamics in two ways: 
 1. by setting the "system" parameter to a system structure:

       sim(ctrl, sysStruct, x0, N, Options)

 2. by setting the "system" parameter to a handle of a function which will
    provide updates of system states in a discrete-time fashion:
        
       sim(ctrl, @sim_function, x0, N, Options)

    Take a look at 'help di_sim_fun' on how to write simulation functions
    compatible with this function.

 ---------------------------------------------------------------------------
 INPUT
 ---------------------------------------------------------------------------
 ctrl    - An MPTCTRL object
 system  - System model to use for simulations. It can either be a sysStruct
           structure or a handle of a function which takes "x_k" and "u_k" as
           input arguments and produces "x_k+1" (state update) and "y_k"
           (system outputs) vectors.
 x0      - Initial state
 N       - Number of simulation steps. If not specified, or defined as an empty
           matrix ([]) or as Inf, simulation is performed until a given
           regulation objective is reached (usually when the origin is reached)
 Options - Additional options. See 'help mpt_computeTrajectory' and 
           'help mpt_getInput' for list of supported options.

 ---------------------------------------------------------------------------
 OUTPUT                                                                                                    
 ---------------------------------------------------------------------------
 X,U,Y    - Matrices which contain evolution of system states, inputs and
            outputs during the simulation
 cost     - Cost associated to the simulated trajectory
 feasible - A true/false flag indicating whether the simulation was feasible

 see also MPT_COMPUTETRAJECTORY, MPT_GETINPUT, MPTCTRL/SIMPLOT

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Thu 30-Mar-2006 10:26:47 by m2html © 2003