Documentation Center

  • Trial Software
  • Product Updates

Log Data Stores

Logging Local and Global Data Store Values

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, see the sldemo_mdlref_dsmsldemo_mdlref_dsm model.

Supported Data Types, Dimensions, and Complexity for Logging Data Stores

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.

Data Store Logging Limitations

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 Model 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 View Sample Time Information.

  • You cannot log data stores that use custom data types.

Logging Data Stores Created with a Data Store Memory Block

To log a local data store that you create with a Data Store Memory block:

  1. In the Block Parameters dialog box for the Data Store Memory block that you want to log, select the Logging pane.

  2. Select the Log signal data check box.

  3. Optionally, specify limits for the amount of data logged, using the Minimum and Maximum parameters.

  4. Enable data store logging with the Model Configuration Parameters > Data Import/Export > Data stores parameter.

  5. Simulate the model.

Logging Icon for the Data Store Memory Block

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.

Logging Data Stores Created with a Simulink.Signal Object

You can create local and global data stores using a Simulink.Signal object. See Data Stores with Signal Objects for details.

To log a data store that you create with a Simulink.Signal object:

  1. Create a Simulink.Signal object in a workspace that is visible to every component that needs to access the data store, as described in Data Stores with Signal Objects.

  2. 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.

  3. 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
  4. 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.

  5. Enable data store logging with the Model Configuration Parameters > Data Import/Export > Data stores parameter.

  6. Simulate the model.

Accessing Data Store Logging Data

The following Simulink® classes represent data from data store logging and provide methods for accessing that data:

ClassDescription
Simulink.SimulationData.BlockPathRepresents a fully specified Simulink block path; use for capturing the full model reference hierarchy
Simulink.SimulationData.DatasetStores logged data elements and provides searching capabilities; use to group Simulink.SimulationData.Element objects in a single object
Simulink.SimulationData.DataStoreMemoryStores logging information from a data store during simulation

Viewing Data Store Data

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_dsmsldemo_mdlref_dsm model illustrates approaches for viewing data store logging data.

Accessing Elements in the 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.

Was this topic helpful?