Simulink Reference    
model

Execute a particular phase of the simulation of a model

Syntax

Description

The model command executes a specific phase of the simulation of a Simulink model whose name is model. Use the command's flag argument to indicate the phase of the simulation to be executed. See Simulating Dynamic Systems for a description of the steps that Simulink uses to simulate a model.

This command is intended to allow linear analysis and other M-file program-based tools to run a simulation step by step, gathering information about the model's states and outputs at each step. It is not intended for interactive use, for example, to debug a model.

Use this command if you want to write an M-file program that needs to examine intermediate results of a simulation. Use the sim command if the program does not need to examine intermediate results. Use the Simulink debugger if you need to examine intermediate results to debug a model.

Arguments

sys
Vector of model size data:
  • sys(1) = number of continuous states
  • sys(2) = number of discrete states
  • sys(3) = number of inputs
  • sys(4) = number of outputs
  • sys(5) = reserved
  • sys(6) = direct-feedthrough flag (1 = yes, 0 = no)
  • sys(7) = number of sample times (= number of rows in ts)
x0
Vector that returns the initial condition of each of the system's states
str
State-ordering strings
ts
An m-by-2 matrix containing the sample time (period, offset) information
t
Time step
x
State vector
u
Inputs
flag
String that indicates the simulation phase to be executed:
  • 'sizes' executes the size computation phase of the simulation. This phase determines the sizes of the model's inputs, outputs, state vector, etc.
  • 'compile' executes the compilation phase of the simulation. The compilation phase propagates signal and sample time attributes. It is equivalent to selecting the Update Diagram (Ctrl-D) option from the Simulink Edit menu.
  • 'update' computes the states of the model's blocks at time t.
  • 'outputs' computes the outputs of the model's blocks at time t.
  • 'deriv' computes the state derivatives of the model's block at time step t.
  • 'term' causes Simulink to terminate simulation of the model.

Examples

This command executes the compilation phase of the vdp model that comes with Simulink.

The following command terminates the simulation initiated in the previous example.

See Also

sim


  Simulation Commands sim