|On this page…|
A root-level Inport, Enable, Trigger, and From Workspace block can import data specified by a MATLAB® timeseries object residing in a workspace.
When you create a MATLAB timeseries object to import data to Simulink®, the time dimension depends on the dimension and the type of signal data.
|Signal Data Dimension or Type||Time Dimension Alignment||Example of timeseries Constructor|
Scalar or a 1D vector
Constructor for a scalar signal. Time is aligned with the first dimension.
t = (0:10)'; ts = timeseries(sin(t), t);
2D (including row and column vectors) or greater
Constructor for a matrix signal. Time is aligned with the last dimension.
t = 0; ts = timeseries([1 2; 3 4], t);
2D row vector, and there is only one time step
t = 0; ts = timeseries([1 2], t, 'InterpretSingleRowDataAs3D', true);
To use a MATLAB timeseries object 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 or to a structure of MATLAB timeseries objects.
You can use the Simulink.Timeseries.convertToMATLABTimeseries method to convert a Simulink.Timeseries object to a MATLAB timeseries object. For example, if sim_ts is a Simulink.Timeseries object, then the following line converts sim_ts to a MATLAB timeseries object:
ts = sim_ts.convertToMATLABTimeseries;