How Simulink Works
Each block within a Simulink model has these general characteristics: a vector of inputs, u, a vector of outputs, y, and a vector of states, x:
The state vector may consist of continuous states, discrete states, or a combination of both. The mathematical relationships between these quantities are expressed by these equations.
Simulation consists of two phases: initialization and simulation. During the initialization phase:
- 1
. - The block parameters are passed to MATLAB for evaluation. The resulting
numerical values are used as the actual block parameters.
- 2
. - The model hierarchy is flattened. Each subsystem that is not a conditionally
executed subsystem is replaced by the blocks it contains.
- 3
. - Blocks are sorted into the order in which they need to be updated. The
sorting algorithm constructs a list such that any block with direct
feedthrough is not updated until the blocks driving its inputs are updated.
It is during this step that algebraic loops are detected. For more information
about algebraic loops, see "Algebraic Loops".
- 4
. - The connections between blocks are checked to ensure that the vector length
of the output of each block is the same as the input expected by the blocks it
drives.
Now the simulation is ready to run. A model is simulated using numerical integration. Each of the supplied ODE solvers (simulation methods) depends on the ability of the model to provide the derivatives of its continuous states. Calculating these derivatives is a two-step process. First, each block's output is calculated in the order determined during the sorting. Then, in a second pass, each block calculates its derivatives based on the current time, its inputs, and its states. The resulting derivative vector is returned to the solver, which uses it to compute a new state vector at the next time point. Once a new state vector is calculated, the sampled data blocks and Scope blocks are updated.
[ Previous | Help Desk | Next ]