| Contents | Index |
You can log the values of a local or global data store data variable for all the steps in a simulation. Two common uses of data store logging are for:
Model debugging – view the order of all data store writes
Confirming a model modification – use the logged data to establish a baseline for comparing results for identifying the impact of a model modification
To see an example of logging a global data store, run the sldemo_mdlref_dsm demo.
You can log data stores that use the following data types:
All built-in data types
Enumerated data types
Fixed-point data types
You can log data stores that use any dimension level or complexity.
Limitations for using data store logging in a model are:
To log data for a data store memory:
Simulate the top-level model in Normal mode.
For local data stores, the model containing the Data Store Memory block must be in model reference Normal mode.
Any block in a referenced model that writes to the data store memory must be executed in model reference Normal mode.
If you set the Configuration Parameters > Solver > Tasking mode for periodic sample times parameter to MultiTasking, then you cannot log Data Store Memory blocks that use asynchronous sample times or hybrid sample times (that is, sample times resulting from when different data sources for the data store have different sample times).
For details about viewing information about sample times, see How to View Sample Time Information.
You cannot log data stores that use custom data types.
To log a local data store that you create with a Data Store Memory block:
In the Block Parameters dialog box for the Data Store Memory block that you want to log, select the Logging pane.
Select the Log signal data check box.
Optionally, specify limits for the amount of data logged, using the Minimum and Maximum parameters.
Enable data store logging with the Configuration Parameters > Data Import/Export > Data stores parameter.
Simulate the model.
When you enable logging for a model, and you configure a local data store for logging, the Data Store Memory block displays a blue icon. If you do not enable logging for the model, then the icon is gray.

You can create local and global data stores using a Simulink.Signal object. See Defining Data Stores with Signal Objects for details.
To log a data store that you create with a Simulink.Signal object:
Create a Simulink.Signal object in a workspace that is visible to every component that needs to access the data store, as described in Defining Data Stores with Signal Objects.
Use the name of the Simulink.Signal object in the Data store name block parameters of the Data Store Read and Data Store Write blocks that you want to write to and read from the data store.
From the MATLAB command line, set DataLogging (which is a property of the LoggingInfo property of Simulink.Signal) to 1.
For example, if you use a Simulink.Signal object called DataStoreSignalObject to create a data store, use the following command:
DataStoreSignalObject.LoggingInfo.DataLogging = 1
Optionally, specify limits for the amount of data logged, using the following properties, which are properties of the LoggingInfo property of the Simulink.Signal object: Decimation, LimitDataPoints, and MaxPoints.
Enable data store logging with the Configuration Parameters > Data Import/Export > Data stores parameter.
Simulate the model.
The following Simulink classes represent data from data store logging and provide methods for accessing that data:
| Class | Description |
|---|---|
| Simulink.SimulationData.BlockPath | Represents a fully specified Simulink block path; use for capturing the full model reference hierarchy |
| Simulink.SimulationData.Dataset | Stores logged data elements and provides searching capabilities; use to group Simulink.SimulationData.Element objects in a single object |
| Simulink.SimulationData.DataStoreMemory | Stores logging information from a data store during simulation |
To view data store logging data from the command line, view the output data set in the base workspace. The default variable for the data store logging data set is dsmout.
The sldemo_mdlref_dsm demo illustrates approaches for viewing data store logging data.
To find an element in the data store logging data, based on the Name or BlockType property, use the getElement method of Simulink.SimulationData.Dataset. For example:
dsmout.getElement('RefSignalVal')
ans =
Simulink.SimulationData.DataStoreMemory
Package: Simulink.SimulationData
Properties:
Name: 'RefSignalVal'
Blockpath: [1x1 Simulink.SimulationData.BlockPath]
Scope: 'local'
DSMWriterBlockPaths: [1x2 Simulinkl.SimulationData.BlockPath]
DSMWriters: [101x1 uint32]
Values: 101x1 timeseries] To access an element by index, use the Simulink.SimulationData.Dataset.getElement method.
![]() | Data Store Examples | Ordering Data Store Access | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |