simulate

Purpose

Simulates evolution of the system

Syntax

data = system.simulate(U)

Description

data = system.simulate(U) computes evolution of system's states and outputs, starting from the system's internal state and using a sequence of inputs U.

Each column of U is interpreted as the control action to use at the m-th step of the simulation. The total number of simulation steps is given by the number of columns of U. To simulate an autonomous system over M steps, you need to define U=zeros(0, M).

This function returns a structure data, which contains the simulated evolution of system's states (in data.X) and the outputs (in data.Y), respectively.

Note that you should always run system.initialize(x0) to set the initial condition prior to running the simulation.

Also note that the simulate method updates the internal system's state. Therefore once the function completes, the internal state will be set to the final value obtained at the end of the simulation.

Input Arguments

U

Matrix of control inputs stored column-wise for each simulation step.

Class: double

Output Arguments

data

Structure with simulated state and output profiles.

Class: struct

Example(s)

Example 1

Define a 1D LTI system ../../../../../fig/mpt/modules/ui/@LTISystem/simulate1.png.
sys = LTISystem('A', 0.9, 'B', 1)
LTISystem with 1 state, 1 input, 0 outputs
Set the system's internal state to ../../../../../fig/mpt/modules/ui/@LTISystem/simulate2.png.
sys.initialize(2.5);
Simulate evolution of the system using the sequence of
    inputs U = [-0.5, 0.1, 2, 0, 0, 1].
U = [-0.5, 0.1, 2, 0, 0, 1];

data = sys.simulate(U)
data = 

    X: [2.5 1.75 1.675 3.5075 3.15675 2.841075 3.5569675]
    U: [-0.5 0.1 2 0 0 1]
    Y: [0x6 double]

Plot the simulated evolution of system's states.
plot(data.X)

../../../../../fig/mpt/modules/ui/@LTISystem/simulate_img_1.png

Note that at the end of simulation, the system's internal state is set to the final state value:
sys.getStates()
ans =

                 3.5569675


© 2003-2013 Michal Kvasnica: STU Bratislava, michal.kvasnica@stuba.sk