Set Priority in Execution Order of Blocks
This example shows how the relative execution priority of blocks in a model affects their execution order. The example model uses three triggered subsystems. Each subsystem is assigned an integer value that indicates the execution priority relative to other subsystems in the model. A smaller Priority value indicates a higher execution priority. In the current configuration, the priority order is set to [ 1 2 3
], as indicated by the block annotation. You can set the priority order to a different value and observe the effect on how the execution order.
To view the execution priority configuration for a Triggered Subsystem, right-click the block and select Properties to open the Block Parameters dialog box. In the dialog box, ensure that Execution Order is set to Based on priority
. The Priority field shows the priority value for the block.
You can change the execution priority of all the blocks at once by changing the value of the mask parameter Priority order
. To change the execution priority, double-click the masked subsystem Set Block Priority
and choose a value for Priority order ([2 1 3]
).
Save the model. Simulate the model again and observe the change in execution order. Each triggered subsystem contains an S-function named spriorityfcn.m
which highlights the blocks in color based on their execution order each time the subsystems execute.
See Also
Triggered Subsystem | Level-2 MATLAB S-Function | S-Function