Model Context

Define the initialization and finalization scripts, and properties for a model.

Initialization Script

An initialization script provides a means for you to define OML variables and functions for a simulation.

On top of the main diagram context, the software applies an initialization script, which is yet another OML script that is executed at the beginning of the simulation process. The main purpose of this script is to define the variables or functions that are required throughout the model during a simulation.

Define Initialization Variables and Functions

Create a script with the OML variables and functions, such as the simulation final time, that you want to be available for a simulation .

  1. From the ribbon, select the the Model Initialization and Properties tool:


    The Model dialog opens.
  2. Select the Initialization tab.
  3. In the OML editor, enter the initialization information for your model. You can include any valid OML command such as a variable definition or function definition/execution.


    Alternatively, if you want to load an existing initialization file, select and navigate to the .oml script you want to load.

Finalization Script

A finalization script provides a means for you to define OML commands that are to be executed at the end of a simulation.

The finalization script lets you define OML commands that are to be automatically executed when a simulation ends, such as plotting results or saving your data to a specified location.

Note that the Finalization Script is executed when the simulation ends (reaches the final time), or is stopped. It is not executed if the simulation is paused.

Define a Finalization Script

Enter the OML commands that you want to be automatically executed at the end of a simulation.

  1. From the ribbon, select the Model Initialization and Properties tool:


    The Model dialog opens.
  2. Select the Finalization tab.
  3. In the OML editor, enter the required OML commands.


    Alternatively, if you have an existing OML script that you want to load, select and navigate to the file.