| Contents | Index |
| 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 type of signal data:
If the signal is a scalar or a 1D vector, then time is first.
Below is an example of a timeseries constructor for a scalar signal. Time is aligned with the first dimension.
t = (0:10)'; ts = timeseries(sin(t)), t);
If the signal dimension is 2D (including row and column vectors) or greater, then time is last.
Below is an example of a timeseries constructor for a matrix signal. Time is aligned with the last dimension.
t = 0; ts = timeseries([1 2; 3 4], t);
If the signal is a 2D row vector, and there is only one time step, then you need align time with the last dimension. Use the following in the constructor:
'InterpretSingleRowDataAs3D', true
For example:
t = 0; ts = timeseries([1 2], t, 'InterpretSingleRowDataAs3D', true);
If you 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 a structure of MATLABtimeseries 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;
![]() | Importing Data to Root-Level Input Ports | Importing Structures of MATLAB timeseries Objects for Bus Signals 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 |