Set Execution Order Property for Block to Execute First
This example shows how to set the execution order of a Data Store Read block to execute first. The execution order specification allows the block to access the data stored in a Data Store Memory block at a previous time step of model simulation.
In this example:
The Data Store Read block reads data stored in the Data Store Memory block.
The Data Store Write block writes data to the Data Store Memory block.
The data store has an initial value of
The input data is a sine wave. At each time step, this data is amplified by a factor of two.
ex_dsrexecutefirst model, the default setting of the Execution Order property for the Data Store Read and Data Store Write blocks is
Based on priority. This execution order setting does not allow the Data Store Read block to access the amplified sine wave value that is stored in the data store at the previous time step. To allow the Data Store Read block to access the data stored at the previous time step, configure the Data Store Read block to execute first.
Open the model.
To display the default execution order, in the Simulink® Editor, on the Debug tab, under Information Overlays, click Execution Order.
Set Data Store Read Block to Execute First
To set up the Data Store Read block to execute first, in the Data Store Read Block Properties dialog box, select
First from the Execution Order property list, select
First. To open the dialog box, right-click on the Data Store Read block and select Properties.
After you change the block configuration, in the model canvas, Simulink adds the label
First above the Data Store Read block.
Display and Verify Updated Execution Order
Update the model (Ctrl+D) for your configuration change to take effect. You can observe the updated execution order in the Execution Order Block List. The updated list shows that the Data Store Read block executes before the Data Store Write block.