| Contents | Index |
A root-level input port defined by a bus object (see Simulink.Bus) can import data from a structure of MATLAB timeseries objects that represent the bus elements for which you do not want to use the ground values. The bus elements that you do not include in the structure use ground values.
The structure of MATLAB timeseries objects must match the bus elements in terms of:
Hierarchy
The name of the structure field (The name property of the timeseries object does not need to match the bus element name.)
Data type
Dimensions
Complexity
The order of the structure fields does not have to match the order of the bus elements.
Although you can use Simulink.TsArray objects for time series data, using MATLAB timeseries objects provides the following benefits:
Creating a Simulink.TsArray object can be difficult and often involves having a harness of models or custom scripts.
Using a structure of MATLAB timeseries objects supports using a partial specification of bus elements (using ground values for those elements that you do not specify in the structure).
The From Workspace block does not support Simulink.TsArray objects.
When the Configuration Parameters > Data Import/Export > Signal logging format parameter is set to ModelDataLogs, the data that comes directly from a logged signal during simulation is stored as Simulink.TsArray objects. Although you can convert the Simulink.TsArray objects to MATLAB timeseries objects, in most situations it makes sense to leave the data in Simulink.TsArray format.
If Signal logging format is set to Dataset, then the data is logged as a structure of MATLAB timeseries objects. For an example of using the Dataset format for signal logging, see sldemo_mdlref_bus.
Note If you use a structure of MATLAB timeseries objects for a root Inport block in a model that has multiple root Inport blocks, convert all of the other root Inport block data that uses Simulink.TsArray or Simulink.Timeseries objects to MATLAB timeseries objects. |
You can create a structure of MATLAB timeseries objects from a Simulink.TsArray object. For example, if tsa is a Simulink.TsArray object:
input = Simulink.SimulationData.createStructOfTimeseries(tsa);
Use the following procedure to set up a model to import bus data to a root Inport block or Trigger blocks.
The examples in this procedure assume you have a model that is set up as follows:
The TopBusObject bus object has two elements:
c
s1, which is a sub-bus that has two elements: a and b.

The model has two root Inport blocks: In1 and In2.
The In1 Inport block imports non-bus data.
The In2 Inport block imports bus data of type TopBusObject.
Create a MATLAB timeseries object for each root Inport or Trigger block for which you want to import non-bus data.
For example:
N = 10; Ts = 1; t1 = ((0:N)* Ts)'; d1 = sin(t1); in1 = timeseries(d1,t1)
Create a structure of MATLAB timeseries objects, with one timeseries object for each leaf bus element for which you do not want to use ground values.
For example, to specify non-ground values for all the elements in the s2 bus:
in2.c = timeseries(d1,t1); in2.s1.a = timeseries(d2,t2); in2.s1.b = timerseries(d3,t3);
The MATLAB timeseries objects that you create must match the corresponding bus element in terms of:
Hierarchy
Name
Data type
Dimensions
Complexity
The name of the structure field must match the bus element name. The Name property of the MATLAB timeseries object does not need to match the bus element name.
The order of the structure fields does not matter.
To determine the number of MATLAB timeseries objects and data type, complexity, and dimensions needed for creating a structure of timeseries objects from a bus, you can use the Simulink.Bus.getNumLeafBusElements and Simulink.Bus.getLeafBusElements methods. For example, you could use these methods in conjunction with the Simulink.SimulationData.createStructOfTimeseries utility (where MyBus is a bus object):
num_el = MyBus.getNumLeafBusElements; el_list = MyBus.getLeafBusElements;
To create a structure of MATLABtimeseries objects from a bus object and a cell array of timeseries or Simulink.Timeseries objects, use the Simulink.SimulationData.createStructOfTimeseries utility. For example:
input = ...
Simulink.SimulationData.createStructOfTimeseries('MyBus',...
{ts1,ts2,ts3});In the Configuration Parameters > Import/Export pane, select the Input parameter and enter a comma-separated list of MATLAB timeseries objects and structures of MATLAB timeseries objects.
For example, the in1 timeseries object and the in2 structure of timeseries objects.

![]() | Importing MATLAB timeseries Data | Importing Simulink.Timeseries and Simulink.TsArray Data to a Root-Level Input Port | ![]() |

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 |