Container for signal data logs of a model
ModelDataLogs class is supported
for backwards compatibility. Starting in R2016a, you cannot log data
ModelDataLogs format. Signal logging
Dataset format. In R2016a or later,
when you open a model from an earlier release that had used
the model simulated in use
You can convert signal logging data from
Dataset format makes it easier
to post-process with other logged data (for example, logged states),
which can also use
Dataset format. For
more information, see Convert Logged Data to Dataset Format.
If you have legacy code that uses the
you can encounter situations that require updates to your code or
model. See Migrate Scripts That Use Legacy ModelDataLogs API.
In releases before R2016a, if you set Configuration
Parameters > Data Import/Export > Signal logging format to
ModelDataLogs, Simulink® software
created instances of the
to contain signal logs while simulating a model. Logging created an
instance of this class for a top model and for each model referenced
by the top model that contains signals to be logged. Logging assigned
ModelDataLogs object for the top model to a
variable in the base workspace. The name of the variable is the name
specified in the Configuration Parameters > Data Import/export > Signal logging
name parameter. The default value is
ModelDataLogs object has a variable number
of properties. The first property, named
specifies the name of the model whose signal data the object contains
or, if the model is a referenced model, the name of the Model block
that references the model. The remaining properties reference objects
that contain signal data logged during simulation of the model. The
objects may be instances of any of the following types of objects:
The names of the properties identify the data being logged as follows:
For signal data logs, the name of the signal
For a subsystem or model log container, the name of the subsystem or model, respectively
Consider, for example, the following model.
As indicated by the testpoint icons, this model specifies that Simulink software
should log the signals named
the root system and the signal named
clk in the
subsystem named Delayed Out. After you simulate this model in a release
earlier than R2016a, the MATLAB® workspace contains the following
Simulink.ModelDataLogs (siglgex): Name elements Simulink Class scope 2 TsArray step 1 Timeseries ('Delayed Out') 2 SubsysDataLogs
You can use fully qualified object names or the Simulink
unpack command to access the signal
data. For example, to access the amplitudes of the
in the Delayed Out subsystem in a
data = logsout.('Delayed Out').clk.Data;
>> logsout.unpack('all'); >> data = clk.Data;
Simulink.ModelDataLogs object contains
signal data objects to capture signal logging information for specific
Signal names in data logs can have spaces or newlines in their names when the signal:
Is named and the name includes a space or newline character.
Is unnamed and originates in a block whose name includes a space or newline character.
Exists in a subsystem or referenced model, and the name of the subsystem, Model block, or of any superior block includes a space or newline character.
The following model shows a signal whose name contains a space, a signal whose name contains a newline, and an unnamed signal that originates in a block whose name contains a newline:
The following example shows how to handle spaces or new lines
in logged names, if a model uses
the signal logging format.
logsout = Simulink.ModelDataLogs (model_name): Name Elements Simulink Class ('x y') 1 Timeseries ('a b') 1 Timeseries ('SL_Sine Wave1') 1 Timeseries
You cannot access any of the
in this log using TAB name completion or by typing the name to MATLAB.
This syntax is not recognized because the space or newline in each
name appears to the MATLAB parser as a separator between identifiers.
??? logsout.x y | Error: Unexpected MATLAB expression.
To reference a
whose name contains a space, enclose the element containing the space
in single quotes:
Name: 'x y' BlockPath: 'model_name/Sine' PortIndex: 1 SignalName: 'x y' ParentName: 'x y' TimeInfo: [1x1 Simulink.TimeInfo] Time: [51x1 double] Data: [51x1 double]
To reference a
whose name contains a newline, concatenate to construct the element
containing the newline:
cr=sprintf('\n') logsout.(['a' cr 'b'])
The same techniques work when a space or newline in a data log derives from the name of:
An unnamed logged signal's originating block
A subsystem or Model block that contains any logged signal
Any block that is superior to such a block in the model hierarchy
This code can reference logged data for the signal:
logsout.(['SL_Sine' cr 'Wave1'])
For names with multiple spaces, newlines, or both, repeat and combine the two techniques as needed to specify the intended name to MATLAB.
ModelDataLogs format stores each
logged bus signal data in a separate
The hierarchy of a bus signal is preserved in the logged signal data. The logged name of a signal in a virtual bus derives from the name of the source signal. The logged name of a signal in a nonvirtual bus derives from the applicable bus object, and can differ from the name of the source signal. See Composite Signals for information about those capabilities.