Access Data Store at Higher Level in Model Hierarchy - MATLAB & Simulink (original) (raw)

This example shows how to access the data stored in the Data Store Memory block at a higher level in the model hierarchy.

In this example:

The DataStoreMemoryTop model shows its Model Properties dialog box open to the Callbacks tab.

Configure Blocks Inside the Referenced Model

At the top-level model, a Model block references to the DataStoreMemoryBot model. To allow the Data Store Read and Data Store Write blocks inside the referenced model to access the data store:

The Data Store Memory Block Parameters dialog box shows the Data store reference option selected.

The Data Store Memory Block Parameters dialog box is open to the Signal Attributes tab.

Upon receiving the Read function-call signal at the read port of the Model block, the Data Store Read block reads data from the data store. The output is displayed at the Scope block. Similarly, when the model receives the Write function-call signal at the write port of the Model block, the input signal value 5 is multiplied by the Gain parameter value 2, and the Data Store Write block writes to the data store.

DataStoreMemoryBot model.

Model Function-Call Events Using Event Scheduler

Use a Stateflow® chart to model an event schedule that generates the Read and Write function-call events based on the sine wave amplitude. These function-call events control the execution of the DataStoreMemoryTop model.

Event Scheduler.

Review Results

Simulate the model.

sim('DataStoreMemoryTop');

The Scope block displays the simulation results.

The model executes based on function-call events. From the Scope block output, you can observe that:

See Also

Data Store Memory | Data Store Read | Data Store Write | Function-Call Subsystem

Topics