This example shows how to view and edit the execution order of function-calls in an export-function model using the Schedule Editor. As in all export-function models, the desired functionality is modeled as function-call subsystems. These function-call subsystems define the partitions that are scheduled by the Schedule Editor.
With the Schedule Editor, you can easily view and edit the schedule of the function-calls. The behavior of the system depends on the execution order of these partitions. In this example, we change the execution order and observe its effects on the behavior of the system by simulating the model. To see the impact of editing the schedule on the simulation, we compare the model simulations before and after scheduling.
To view and edit the schedule of the export-function model, reference the model.
ThrottlePositionControl is the referenced export-function model. By default, each function has an input port that can be used to trigger these functions. The Schedule Editor automatically handles these ports. To use the Schedule Editor, set the Schedule Rates With parameter to Schedule Editor.
To observe the impact of scheduling on the model behavior, establish a baseline by simulating the model before editing the schedule. Simulate the model.
To open the Schedule Editor, click Schedule Editor in the Design section of the Modeling tab. In the Schedule Editor, different components of the model are represented as partitions. Update the diagram to see the partitions. Partitions are the entry-points in the model. The Schedule Editor shows the execution order and data communications of these partitions. The arrows are data connections between the partitions that show the data flow. The dashed lines indicate that there is a delay because the source runs after the destination. The solid lines indicate that there is no delay as the source runs before the destination.
The Execution Order shows the order the partitions run in at a given time step. Assume that the execution order of the partitions is in an imperfect state. In this case, to remove the delay, you want to run the
ThrottleComposition.ActuatorRun5ms partition after the
ThrottleComposition.ActuatorRun5ms after the
ThrottleComposition.ControllerRun5ms in the execution order. Observe that the delay between the
ThrottleComposition.ControllerRun5ms and the
ThrottleComposition.ActuatorRun5ms partitions changes to a dependency. Observe that now there is no delay between the executions of
The export-function model contains an unconstrained partition,
AccelerationPedalPositionSensor. Suppose you want to schedule an unconstrained partition to simulate as if it were discrete. Schedule
AccelerationPedalPositionSensor partition to run at [0:0.02:100] to observe its behavior at different instances of time. Click the unconstrained partition and enter [(1:5000)*.02] for Hit Times in the Property Inspector.
Now, simulate the model with the changed schedule.
Open the Simulation Data Inspector. Select the two runs and compare. You can see how changing the schedule impacts the model behavior. For more information, see View Data with the Simulation Data Inspector.
Copyright 2018-2019 The MathWorks, Inc.