Data Stores with Signal Objects

Creating the Data Store

To use a Simulink.Signal object to define a data store without using a Data Store Memory block, create the signal object in a workspace that is visible to every component that needs to access the data store. The name of the associated data store is the name of the signal object. You can use this name in Data Store Read and Data Store Write blocks, just as if it were the Data store name of a Data Store Memory block. Simulink® creates an associated data store when you use the signal object for data storage.

Local and Global Data Stores

You can use a Simulink.Signal object to define either a local or a global data store.

  • If you define the object in the MATLAB® base workspace, the result is a global data store, which is accessible in every model within Simulink, including all referenced models.

  • If you create the object in a model workspace, the result is a local data store, which is accessible at every level in a model except any referenced models.

Signal Object Attributes for Data Stores

Those data store attributes that a signal object does not define have the same default values that they do in a Data Store Memory block. The parameter values of a signal object used as a data store have different requirements, depending on whether the data store is local or global.

Once you have created the object, set the properties of the signal object to the values that you want the corresponding data store properties to have. For example, the following commands define a data store named Error in the MATLAB base workspace:

Error = Simulink.Signal;
Error.Description = 'Use to signal that subsystem output is invalid';
Error.DataType = 'boolean';
Error.Complexity = 'real';
Error.Dimensions = 1;
Error.SamplingMode='Sample based';
Error.SampleTime = 0.1;

Attributes for Local Data Stores

For a local data store, for each parameter listed below, you can either set the value explicitly or you can have the data store inherit the value from the Data Store Write and Data Store Read blocks.

  • DataType

  • Complexity

  • SampleTime

  • SamplingMode

To define a local data store using a Data Store Memory block, you can use a signal object for the Data store name parameter. For compile-time checking, in the Signal Attributes tab, select the Data store must resolve to Simulink signal object parameter. The Data store must resolve to Simulink signal object parameter causes Simulink to display an error and stop compilation if Simulink cannot find the signal object or if the signal object properties are inconsistent with the signal object properties.

Attributes for Global Data Stores

The following table describes the parameter requirements for global data stores.

ParameterGlobal Data Store Value
DataTypeMust be set explicitly
ComplexityMust be set explicitly
DimensionsCan be set or inherited
SampleTimeCan be set or inherited
SamplingModeMust be 'Sample based'

Was this topic helpful?