This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Data Store Write

Write data to data store

  • Library:
  • Simulink / Signal Routing

Description

The Data Store Write block copies the value at its input to the named data store. Each write operation performed by a Data Store Write block writes over the data store, replacing the previous contents.

The data store to which this block writes is determined by the location of the Data Store Memory block or signal object that defines the data store. For more information, see Data Stores and Data Store Memory. The size of the data store is set by the signal object or the Data Store Memory block that defines and initializes the data store. Each Data Store Write block that writes to that data store must write the same amount of data.

More than one Data Store Write block can write to the same data store. However, if two Data Store Write blocks attempt to write to the same data store during the same simulation step, results are unpredictable.

Obtaining correct results from data stores requires ensuring that data store reads and writes occur in the expected order. For details, see Order Data Store Access and Data Store Diagnostics.

You can log the values of a local or global data store data variable for all the steps in a simulation. For details, see Log Data Stores.

Ports

Input

expand all

Values to write to the specified data store. The Data Store Write block accepts a real or complex signal.

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

To assign a subset of the bus or matrix elements to the associated data store, use the Element Assignment pane. The Data Store Write block icon reflects the elements that you specify. For details, see Accessing Specific Bus and Matrix Elements.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | enumerated | bus

Parameters

expand all

Arguments

Specifies the name of the data store to which this block writes data. The adjacent drop-down list provides the names of Data Store Memory blocks that exist at the same level in the model as the Data Store Write block or at higher levels. The drop-down list also includes all Simulink.Signal objects in the base and model workspaces. To change the name, select a name from the drop-down or enter the name directly in the edit field.

When Simulink® software compiles the model containing this block, Simulink searches the model upwards from this block's level for a Data Store Memory block having the specified data store name. If Simulink does not find such a block, it searches the model workspace and the MATLAB® workspace for a Simulink.Signal object having the same name. If Simulink finds neither the Data Store Memory block nor the signal object, it halts the compilation and displays an error. See Symbol Resolution for more information about the search path.

If Simulink finds a signal object, it creates a hidden Data Store Memory block at the model's root level having the properties specified by the signal object and an initial value set to a matrix of zeros. The dimensions of that matrix are inherited from the Dimensions property of the signal object.

Programmatic Use

Block Parameter: DataStoreName
Type: character vector
Values: data store name
Default: 'A'

This field lists the Data Store Memory block that initialized the store to which this block writes.

This field lists the path to all Data Store Read blocks with the same data store name as this block that are in the same (sub)system or in any subsystem below it in the model hierarchy. Click any entry in this list to highlight the corresponding block in your model.

The sample time, which controls when the block writes to the data store. A value of -1 indicates that the sample time is inherited. See Specify Sample Time for more information.

Programmatic Use

Block Parameter: SampleTime
Type: character vector
Values: scalar | vector
Default: '-1'

Element Assignment

List of elements in the associated data store. For data stores with arrays, you can write the whole data store, or you can assign one or more elements to the whole data store. For data stores with a bus data type, you can expand the tree to view the bus elements. The list displays the maximum dimensions for each element, in parentheses.

You can select an element and then use one of the following approaches:

  • Click Select>> to display that element (and all its subelements) in the Selected element(s) list.

  • Use the Specify element(s) to select edit box to specify the elements that you want to select for writing. Then click Select>>.

To refresh the display and reflect modifications to the array or bus used in the data store, click Refresh.

Dependencies

The prompt for this section (Elements in the array or Signals in the bus) depends on the type of data in the data store.

Programmatic Use

Block Parameter: DataStoreElements
Type: character vector
Values: pound-delimited list of elements (See Specification using the command line.)
Default: ''

Enter a MATLAB expression to define the specific element that you want to write. For example, for a data store named DSM that has maximum dimensions of [3,5], you could enter expressions such as DSM(2,4) or DSM([1 3],2) in the edit box. Then click Select>>.

To apply the element selection, click OK or Apply.

Programmatic Use

Block Parameter: DataStoreElements
Type: character vector
Values: pound-delimited list of elements (See Specification using the command line.)
Default: ''

Displays the elements that you selected for assignment. The Data Store Write block icon displays a port for each element that you specify.

To change the order of bus or matrix elements in the list, select the element in the list and click Up or Down. Changing the order of the elements in the list changes the order of the ports. To remove an element, click Remove.

Programmatic Use

Block Parameter: DataStoreElements
Type: character vector
Values: pound-delimited list of elements (See Specification using the command line.)
Default: ''

Block Characteristics

Data Types

Boolean | bus | double | enumerated | fixed point | integer | single | string

Direct Feedthrough

no

Multidimensional Signals

yes

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Fixed-Point Conversion
Convert floating-point algorithms to fixed point using Fixed-Point Designer™.

Introduced before R2006a