Main Content

Dataset signal format

Description

Format for logged Dataset leaf elements.

Category: Data Import/Export

Settings

Default: timeseries

timeseries

Save Dataset element values in MATLAB® timeseries format. Logged data for variable-size signals is always stored in a timetable that contains a cell array of signal values for each time step.

timetable

Save Dataset element values in MATLAB timetable format.

Comparison of Formats

The timetable format enables easier merging of logged data from multiple simulations.

Property Display

The timeseries format displays one field for time properties (TimeInfo) and a second field for data properties (DataInfo). For example, here are the properties of a timeseries object for a nonscalar signal.

ts
 timeseries

  Common Properties:
            Name: ''
            Time: [1001x1 double]
        TimeInfo: [1x1 tsdata.timemetadata]
            Data: [1001x1 double]
        DataInfo: [1x1 tsdata.datametadata]
 

When you enter the name of a timetable object (for example, tt) and query the properties, you see all of the properties.

tt.Properties
ans =

  struct with fileds:

           Description: ''
              UserData: []
        DimensionNames: {'Time' 'Variables'}
  VariableDescriptions: {}
         VariableNames: ['temperature' 'WindSpeed' 'WindDirection']
         VariableUnits: {}
    VariableContinuity: ['continuous']
              RowTimes: [64x1 duration]
              

Data Access

To access data logged in the timeseries format, use the Data property for a signal. For example, for a timeseries object ts (only first five values shown):

ts = yout{1}.Values;
ts.Data
ans =

         0
   -0.0002
   -0.0012
   -0.0062
   -0.0306
   

The timetable format for logged Dataset data produces a table with one time column, called Time, and one data column, called Data. The Time column is the simulation time vector for a given signal, stored as a duration type, with the setting of seconds to match the units of simulation time, starting with the simulation start time (typically set to 0 sec). The Simulink® signal dimensions of [n] and [nx1] are treated equivalently in the timetable representation. For example, for a timetable object tt (only first five values shown):

tt = yout{1}.Values;
tt.Data
       Time                Data
    _________        ____________

       0 sec         [1x3x2 double]
     0.1 sec         [1x3x2 double]
     0.2 sec         [1x3x2 double]
     0.3 sec         [1x3x2 double]
     0.4 sec         [1x3x2 double]

The number of samples is the first dimension in the Data column of the timetable object, but it is the last dimension in the data field of logged timeseries data that is nonscalar. Therefore, when you access data in timetable format, you may need to reshape the data when each sample is a nonscalar array. One option is to use the squeeze function. For example, to access the first data row in the dataset, you can use a command like this:

squeeze(tt.Data{1,1})
ans =
      1    2
      3    4
      5    6

If a signal is a bus or array of buses, the signal values are logged as a structure of timetable objects, with each leaf of the structure corresponding to the logged result of each leaf signal in the bus.

Units

For data logged in Simulink, the timeseries format displays units for time values in the Units property. Units can be specified as any value of any class. Timeseries logging sets the units to a Simulink.SimulationData.Unit object, if the logged signal has units specified. For loading, units are honored only if they are of type Simulink.SimulationData.Unit; otherwise, they are ignored.

For the timetable format, Simulink does not support units for logged data.

Data Interpolation

The timeseries format Interpolation property displays whether the interpolation method is linear (default) or zoh.

The timetable format VariableContinuity property characterizes variables as continuous or discrete. The possible values for simulation data are:

  • continuous – Corresponds to the timeseries property Interpolation setting of linear. Simulink uses this setting for filling continuous sample times.

  • step – Corresponds to the timeseries property Interpolation setting of zoh.

    Simulink uses this setting for filling discrete sample times.

Uniform and Nonuniform Time

The timeseries format displays whether the time data is uniform or nonuniform. For data logged for continuous sample times (linear interpolation), the TimeInfo property indicates that the time is nonuniform and gives the length. For a discrete sample times (zero-order hold interpolation), the TimeInfo property indicates that the time is uniform and gives the length and increment.

The timetable format does not have a property for uniform and nonuniform time data.

For data in timeseries or timetable format, you can use the MATLAB isregular function to get this time information.

Signal Name

The timeseries format stores the name of a logged signal in a Simulink.SimulationData.Element wrapper object, as well as in the timeseries object itself.

The timetable format stores the name of a logged signal in a Simulink.SimulationData.Element wrapper object, but not in the timetable object itself.

Tips

  • The Dataset signal format parameter has no effect when using Scope blocks to log data.

Programmatic Use

Parameter: DatasetSignalFormat
Value: 'timeseries' | 'timetable'
Default: 'timeseries'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
Efficiency

No recommendation

Safety precaution

No recommendation

Related Topics