Main Content

Schedule an Export-Function Model Using the Schedule Editor

This example shows how to view and edit the 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 order of these partitions. In this example, we change the 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.

Create Partitions from Referenced Export-Function Model

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.

set_param('ThrottlePositionControlTop/ThrottleControl','ScheduleRatesWith','Schedule Editor');

Establish a Simulation Baseline

To observe the impact of scheduling on the model behavior, establish a baseline by simulating the model before editing the schedule. Simulate the model.


Open the Schedule Editor

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 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.

Edit Partition Schedule

The Order pane shows the order the partitions run in at a given time step. Assume that the order of the partitions is in an imperfect state. In this case, to remove the delay, you want to run the ThrottleControl.ActuatorRun5ms partition after the ThrottleControl.ControllerRun5ms partition.

Drag ThrottleControl.ActuatorRun5ms after the ThrottleControl.ControllerRun5ms in the Order pane. Observe that the delay between the ThrottleControl.ControllerRun5ms and the ThrottleControl.ActuatorRun5ms partitions changes to a dependency. Observe that now there is no delay between the executions of ThrottleControl.ControllerRun5ms and ThrottleControl.ActuatorRun5ms.

Schedule the Execution of Aperiodic Partitions

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 ThrottleControl.AppSnsrRun 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 Trigger in the Property Inspector.

Compare the Runs in Simulation Data 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.

Copyright 2018-2022 The MathWorks, Inc.