Context
A context is an OML script for defining variables in a diagram.
A context is an OML script associated at each level of the hierarchy of a model. A model includes a main diagram with its own context. If the main diagram includes super blocks, each super block can have its own context. Contexts are semi-global, meaning a variable defined in a diagram applies to that diagram and in diagrams at all levels below unless the context of a lower-level diagram is defined.
Because a model can be hierarchical and variables can be defined at different levels, the software offers the Available Variables option which lets you navigate in a diagram and get a report of all variables that are known or defined at a current level.
Define a Context
Define a context inside of a diagram.
The Diagram Context tab contains an OML text editor for defining variables in a script for use in the definition of block parameters. All OML functions available in OML libraries are valid to enter into the script. All the variables that you define in the script are placed in the scope of the diagram and can be used to define block parameters in that diagram in addition to offspring diagrams and their contexts, as long as those variables are not redefined by another context.
For example, if you enter in a script a=3
, then the variable
a can be used to define the gain parameter of a Gain block as
“2*cos(a)”
in a diagram.