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
-5.The input data is a sine wave. At each time step, this data is amplified by a factor of two.
In the 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.
open_system('ex_dsrexecutefirst')To display the default execution order, in the Simulink® Editor, on the Debug tab, in the Diagnostics section, 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:
Open the Block Properties dialog box. To open the dialog box, right-click the Data Store Read block, and then click the Properties button.

2. In the dialog box, from the Execution Order drop-down options, select First. Then, click Apply and OK.

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.

See Also
Data Store Memory | Data Store Read | Data Store Write