Convert Timeseries to Timetable for an R202a version.

6 visualizzazioni (ultimi 30 giorni)
before Matlab version R2021b, how do we convert a Timeseries to a Timetable?
Can I also get the raw functionf file, so that I make a local function that does that conversion on my laptop?

Risposte (1)

recent works
recent works il 4 Set 2023
  1. Create a new variable to store the converted timetable.
  2. Use the array2timetable function to convert the Timeseries to an array. The first argument to the array2timetable function is the Timeseries array, and the second argument is a vector of row times. The row times can be a vector of datetime or duration values.
  3. Assign the output of the array2timetable function to the new variable.
ts = timeseries(rand(5,1),[0 10 20 30 40]);
TT = array2timetable(ts,[0 10 20 30 40]);
This code creates a Timeseries array called ts with 5 data points, sampled at 10 second intervals. It then converts ts to a Timetable array called TT. The row times in TT are the same as the sample times in ts.
You can get the raw function file for the array2timetable function from the MathWorks website. The file is located in the following directory:
<MATLAB_ROOT>\toolbox\matlab\datafun\array2timetable.m
Once you have the function file, you can copy it to your laptop and create a local function that does the conversion.
Example
function TT = timeseries2timetable(ts)
% Convert a Timeseries to a Timetable
TT = array2timetable(ts,ts.Time);
end
This function takes a Timeseries array as input and returns a Timetable array as output. The output Timetable array has the same data as the input Timeseries array, and the row times are the same as the sample times in the input Timeseries array.
  2 Commenti
Praise Nwachukwu
Praise Nwachukwu il 4 Set 2023
From the code documentation as posted, it says "2021b" version, that's why I structured my question the way it was.
I am quite aware of the function, TT = timeseries2timetable(x), but it doesn't work for my version. What do I do?
Praise Nwachukwu
Praise Nwachukwu il 4 Set 2023
So, do I have to get a current version or there is another way around it.
If there is, please, I am open to knowing it

Accedi per commentare.

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by