Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Data Store Memory

Define data store

Library

Signal Routing

Description

The Data Store Memory block defines and initializes a named shared data store, which is a memory region usable by Data Store Read and Data Store Write blocks that specify the same data store name.

The location of the Data Store Memory block that defines a data store determines which Data Store Read and Data Store Write blocks can access the data store:

  • If the Data Store Memory block is in the top-level system, Data Store Read and Data Store Write blocks anywhere in the model can access the data store.

  • If the Data Store Memory block is in a subsystem, Data Store Read and Data Store Write blocks in the same subsystem or in any subsystem below it in the model hierarchy can access the data store.

Data Store Read or Data Store Write blocks cannot access a Data Store Memory block that is either in a model that contains a Model block or in a referenced model.

Do not include a Data Store Memory block in a subsystem that a For Each Subsystem block represents.

Use the Initial value parameter to initialize the data store. Specify a scalar value or an array of values in the Initial value parameter. The dimensions of the array determine the dimensionality of the data store. Any data written to the data store must have the dimensions designated by the Initial value parameter. Otherwise, an error occurs.

Obtaining correct results from data stores requires ensuring that data store reads and writes occur in the expected order. For details, see:

You can use Simulink.Signal objects in addition to, or instead of, Data Store Memory blocks to define data stores. A data store defined in the base workspace with a signal object is a global data store. Global data stores are accessible to every model, including all referenced models. See Data Stores for more information.

Data Type Support

The Data Store Memory block stores real or complex signals of any data type that Simulink® supports, including fixed-point, bus object, and enumerated data types.

    Note:   If you specify a bus object as the data type for this block, do not set the minimum and maximum values for bus data on the block. Simulink ignores these settings. Instead, set the minimum and maximum values for bus elements of the bus object specified as the data type. The values should be finite real double scalar.

    For information on the Minimum and Maximum properties of a bus element, see Simulink.BusElement.

For more information, see Data Types Supported by Simulink in the Simulink documentation.

You can use arrays of buses with a Data Store Memory block. For details about defining and using an array of buses, see Combine Buses into an Array of Buses.

Parameters and Dialog Box

The Main pane of the Data Store Memory block dialog box appears as follows:

Data store name

Specify a name for the data store you are defining with this block. Data Store Read and Data Store Write blocks with the same name can read from, and write to, the data store initialized by this block. The name can represent a Data Store Memory block or a sign object defined to be a data store.

Corresponding Data Store Read/Write blocks

List all the Data Store Read and Data Store Write blocks that have the same data store name as the current block, and that are in the current system or in any subsystem below it in the model hierarchy. Double-click a block in this list to highlight the block and bring it to the foreground.

The Signal Attributes pane of the Data Store Memory block dialog box appears as follows:

Initial value

Specify the initial value or values of the data store. The dimensions of this value determine the dimensions of data that may be written to the data store. The Minimum parameter specifies the minimum value for this parameter, and the Maximum parameter specifies the maximum value.

Initial value dimensions must match the dimensions that you specify in the Signal Attributes > Dimensions parameter, unless the initial value is a MATLAB® structure.

Minimum

Specify the minimum value that the block should output. The default value is [] (unspecified). This number must be a finite real double scalar value.

    Note:   If you specify a bus object as the data type for this block, do not set the minimum value for bus data on the block. Simulink ignores this setting. Instead, set the minimum values for bus elements of the bus object specified as the data type. For information on the Minimum property of a bus element, see Simulink.BusElement.

Simulink uses the minimum value to perform:

Maximum

Specify the maximum value that the block should output. The default value is [] (unspecified). This number must be a finite real double scalar value.

    Note:   If you specify a bus object as the data type for this block, do not set the maximum value for bus data on the block. Simulink ignores this setting. Instead, set the maximum values for bus elements of the bus object specified as the data type. For information on the Maximum property of a bus element, see Simulink.BusElement.

Simulink uses the maximum value to perform:

Data type

Specify the output data type. You can set it to:

  • A rule that inherits a data type (for example, Inherit: auto)

  • The name of a built-in data type (for example, single)

  • The name of a data type object (for example, a Simulink.NumericType object)

  • An expression that evaluates to a data type (for example, fixdt(1,16,0)). Do not specify a bus object as the data type in an expression; use Bus: <object name> to specify a bus data type.

  • Bus: <object name>; enter the name of a bus object that you want to use to define the structure of the bus. The bus must be a nonvirtual bus. If you need to create or change a bus object, click the Show data type assistant button and then click the Edit button to the right of the Bus object field to open the Simulink Bus Editor. For details about the Bus Editor, see Manage Bus Objects with the Bus Editor

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Data type parameter.

See Specify Block Output Data Types.

Lock output data type setting against changes by the fixed-point tools

Select to lock the output data type setting of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor. For more information, see Use Lock Output Data Type Setting.

Signal type

Specify the numeric type, real or complex, of the values in the data store.

Dimensions (-1 to infer from Initial value)

Specify dimensions that match the dimensions of the Initial value dimensions, unless you specify a MATLAB structure for the initial value. For example, if you use a MATLAB structure for the initial value, then you need to specify dimensions to initialize an array of buses with this MATLAB structure.

Interpret vector parameters as 1-D

If you enable this option and specify the Initial value parameter as a column or row matrix, Simulink initializes the data store to a 1-D array whose elements are equal to the elements of the row or column vector. See Determining the Output Dimensions of Source Blocks.

Data store must resolve to Simulink signal object

Specify that Simulink software, when compiling the model, searches the model and base workspace for a Simulink.Signal object having the same name, as described in Symbol Resolution. If Simulink does not find such an object, the compilation stops, with an error. Otherwise, Simulink compares the attributes of the signal object to the corresponding attributes of the Data Store Memory block. If the block and the object attributes are inconsistent, Simulink halts model compilation and displays an error.

Package

Select a package that defines the custom storage class you want to apply. If you have defined any packages of your own, click Refresh. This action adds all user-defined packages on your search path to the package list.

Storage class

Select a custom storage class for the signal object. When no Package is selected, setting this parameter to ExportedGlobal, ImportedExtern, or ImportedExternPointer enables Storage type qualifier.

Storage type qualifier

Specify the Simulink Coder storage type qualifier.

See States in the Simulink Coder™ documentation for more information.

The Diagnostics pane of the Data Store Memory block dialog box appears as follows:

Detect read before write

Select the diagnostic action to take if the model attempts to read data from a data store to which it has not written data in this time step. See also the Detect read before write diagnostic in the Data Store Memory Block section of the Model Configuration Parameters > Diagnostics > Data Validity pane.

Default: warning

none

Take no action.

warning

Display a warning.

error

Terminate the simulation and display an error message.

Detect write after read

Select the diagnostic action to take if the model attempts to write data to the data store after previously reading data from it in the current time step. See also the Detect write after read diagnostic in the Data Store Memory Block section of the Model Configuration Parameters > Diagnostics > Data Validity pane.

Default: warning

none

Take no action.

warning

Display a warning.

error

Terminate the simulation and display an error message.

Detect write after write

Select the diagnostic action to take if the model attempts to write data to the data store twice in succession in the current time step. See also the Detect write after write diagnostic in the Data Store Memory Block section of the Model Configuration Parameters > Diagnostics > Data Validity pane.

Default: warning

none

Take no action.

warning

Display a warning.

error

Terminate the simulation and display an error message.

The Logging pane of the Data Store Memory block dialog box appears as follows:

Log signal data

Select this option to save the values of this signal to the MATLAB workspace during simulation. See Signal Logging for details.

Logging name

Use this pair of controls, consisting of a list box and an edit field, to specify the name associated with logged signal data.

Simulink uses the signal name as its logging name by default. To specify a custom logging name, select Custom from the list box and enter the custom name in the adjacent edit field.

Data

Use this group of controls to limit the amount of data that Simulink logs for this signal.

  • Limit data points to last: Discard all but the last N data points, where N is the number that you enter in the adjacent edit field.

  • Decimation: Log every Nth data point, where N is the number that you enter in the adjacent edit field. For example, suppose that your model uses a fixed-step solver with a step size of 0.1 s. If you select this option and accept the default decimation value (2), Simulink records data points for this signal at times 0.0, 0.2, 0.4, and so on.

For more information, see Log Data Stores

Characteristics

Sample Time

N/A

Dimensionalized

Yes

Multidimensionalized

Yes

Was this topic helpful?