Main Content

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 to identify the impact of a model modification

For an example of logging a global data store, see Use Data Stores Across Multiple Models.

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.

  • You cannot log data stores that use custom data types, including buses.

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 model, open the Model Data Editor. In the Modeling tab, click Model Data Editor.

  2. On the Data Stores tab, set the Change view drop-down list to Instrumentation.

  3. In the data table, for the target data store, select the check box in the Log Data column.

    If the target data store does not appear in the table, click the Change scope button to display data stores that are defined in subsystems below your current system.

  4. Optionally, to configure additional logging characteristics such as the maximum number of data points to log, open the Property Inspector (in the Modeling tab, under Design, click Property Inspector). Use the Property Inspector to open the block dialog box and inspect the Logging tab.

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

  6. 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:

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

You can also convert data logged in formats other than Dataset. For more information, see Convert Data to Dataset Format.

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.

To view data store logging data, see Use Data Stores Across Multiple Models.

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:


ans = 
Package: Simulink.SimulationData

                 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.

See Also

| |

Related Topics