How can I change timetable to timeseries?

Hello everyone,
I am trying to convert a timetable (DD:MM:YYYY HH::MM:SS) into a time series so that I can run it in Simulink but have trouble doing so. Is anyone able to help me out?

 Akzeptierte Antwort

Star Strider
Star Strider am 1 Mai 2025

0 Stimmen

According to the timeseries documentation, it wants the data values as the first argument, and the time values as the second argument.
From the documentation:
ts = timeseries(datavals,timevals) specifies the sample times for the series. The resulting object sorts the data by time.
.

4 Kommentare

may95
may95 am 1 Mai 2025
Thanks. I have tried and it still won't budge however:
I have also switched the columns in the csv file. But I think the table2timetable function switches it back.
Perhaps something like this —
T = table(datetime(2018,1,1)+seconds(0:3600*3-1).', 1.4000+(0:3600*3-1).'/1E4, VariableNames=["Time","Tamb"]);
TT = table2timetable(T)
TT = 10800x1 timetable
Time Tamb ____________________ ______ 01-Jan-2018 00:00:00 1.4 01-Jan-2018 00:00:01 1.4001 01-Jan-2018 00:00:02 1.4002 01-Jan-2018 00:00:03 1.4003 01-Jan-2018 00:00:04 1.4004 01-Jan-2018 00:00:05 1.4005 01-Jan-2018 00:00:06 1.4006 01-Jan-2018 00:00:07 1.4007 01-Jan-2018 00:00:08 1.4008 01-Jan-2018 00:00:09 1.4009 01-Jan-2018 00:00:10 1.401 01-Jan-2018 00:00:11 1.4011 01-Jan-2018 00:00:12 1.4012 01-Jan-2018 00:00:13 1.4013 01-Jan-2018 00:00:14 1.4014 01-Jan-2018 00:00:15 1.4015
ts = timeseries(TT.Tamb, seconds(TT.Time-TT.Time(1)))
timeseries Common Properties: Name: 'unnamed' Time: [10800x1 double] TimeInfo: tsdata.timemetadata Data: [10800x1 double] DataInfo: tsdata.datametadata
.
ts = timeseries(TT.Tamb, seconds(TT.Time-TT.Time(1)))
This worked! Thank you so much I could hug you through my screen.
Star Strider
Star Strider am 9 Mai 2025
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 1 Mai 2025

0 Stimmen

timeseries() does not accept duration or datetime times.
"Sample times, specified as a numeric scalar or vector, or a cell array of date character vectors. Valid date character vectors can have the following forms:"
You can use
ts = timeseries(Tsec{:,:}, datestr(Tsec.Properties.RowTimes));

3 Kommentare

may95
may95 am 9 Mai 2025
Hi, thank you for your suggestion. Unfortunately my computer memory does not allow to run it.
Could there be a different function, perhaps?
may95
may95 am 9 Mai 2025
Thank you for sending me this information, I didn't know this existed before. Unfortunately this caused the computer to shut down so it didn't work. Also tried Java Heap Cleaner and didn't help. Another user has answered my question. Thank you for your help! :)

Melden Sie sich an, um zu kommentieren.

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by