Why does "ts2timetable" produce error "The VariableUnits property must have one element for each variable in the table." in MATLAB R2021a Prerelease?

3 views (last 30 days)
I have an array of timeseries objects. I would like to transform them into a timetable using the "ts2timetable" function. Specifically,
>> tt = ts2timetable(tsObj1, tsObj2, tsObj3);
However, I encountered an error:
Error using ts2timetable (line 83)
The VariableUnits property must have one element for each variable in the table.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Mar 2021
The error is related to the "DataInfo.Units" property in the timeseries objects.
Note that the timeseries objects that are used as inputs to "ts2timetable" must all have specified units for "DataInfo.Units", or all have empty DataInfo.Units.
If not, the error would be generated. For example, if tsObj1.DataInfo.Units = 'unit1' while tsObj2 and tsObj3 have empty DataInfo.Units, there would be an error.
To fix the error, set or unset DataInfo.Units for all timeseries objects. Using the above example, you can provide a unit to the second and third timeseries objects as follows:
>> tsObj2.DataInfo.Units = 'unit2';
>> tsObj3.DataInfo.Units = 'unit3';
>> tt = ts2timetable(tsObj1, tsObj2, tsObj3);

More Answers (0)

Categories

Find more on Time Series in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!