SIMPLOT Plots a simulated trajectory --------------------------------------------------------------------------- DESCRIPTION --------------------------------------------------------------------------- Plots trajectory of a given closed-loop system starting from a given initial state x0. If the state is not provided and the controller is an explicit control law in exactly 2D, it is possible to select the initial state by mouse, i.e.: simplot(ctrl) or simplot(ctrl, Options) If the initial state is provided, evolution of system states, inputs and outputs is plotted versus the time axis: simplot(ctrl, x0) By default the simulation is stopped when a given control objective is reached (usually when the state reaches the origin). It is, however, possible to tell the function to only compute the evolution for a given number of steps: simplot(ctrl, x0, N) Additional options can also be specified: simplot(ctrl, x0, Options) or simplot(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: simplot(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: simplot(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: simplot(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_PLOTTRAJECTORY, MPT_PLOTTIMETRAJECTORY, MPTCTRL/SIM