|On this page…|
To use a Data Store Memory block to define a data store, drag an instance of the block into the model at the topmost level from which you want the data store to be visible. The result is a local data store, which is not accessible within referenced models.
To define a data store that is visible at every level within a given model, except within Model blocks, drag the Data Store Memory block into the root level of the model.
To define a data store that is visible only within a particular subsystem and the subsystems that it contains, but not within Model blocks, drag the Data Store Memory block into the subsystem.
Once you have added the Data Store Memory block, use its parameters dialog box to define the data store's properties. The Data store name property specifies the name to of the data store that the Data Store Write and Data Store Read blocks access. See Data Store Memory documentation for details.
You can specify data store properties beyond those definable with Data Store Memory block parameters by selecting the Data store name must resolve to Simulink signal object option and using a signal object as the data store name. See Specifying Attributes Using a Signal Object for details.
A Data Store Memory block can inherit three data attributes from its corresponding Data Store Read and Data Store Write blocks. The inheritable attributes are:
However, allowing these attributes to be inherited can cause unexpected results that can be difficult to debug. To prevent such errors, use the Data Store Memory block dialog or a Simulink.Signal object to specify the attributes explicitly.
You can use the Data Store Memory block dialog box to specify the data type and complexity of a data store. In the next figure, the dialog box sets the Data type to uint16 and the Signal type to real.
You can use a Simulink.Signal object to specify data store attributes for a Data Store Memory block.
Tip To establish an implicit data store, as described in Data Stores with Signal Objects, use the same general approach as when you explicitly associate a signal object with a Data Store Memory block.
The next figure shows a Data Store Memory block that specifies resolution to a Simulink.Signal object, named A. To use a signal object for the data store, set Data store name to the name of the signal object. For compile-time checking, open the Signal Attributes tab and select the Data store name must resolve to Simulink signal object parameter.
The signal object specifies values for all three data attributes that the data store would otherwise inherit. In this example, which defines a local data store, the Simulink.Signal object A has the following inherited properties: DataType, Complexity, and SampleTime.
A = Simulink.Signal (handle) CoderInfo: [1x1 Simulink.SignalCoderInfo] Description: '' DataType: 'auto' Min:  Max:  DocUnits: '' Dimensions: 1 DimensionsMode: 'auto' Complexity: 'auto' SampleTime: -1 SamplingMode: 'auto' InitialValue: 0
For more information about specifying signal object attributes for local and global data stores, see Signal Object Attributes for Data Stores.