table2timeseries
convert a table into a timeseries
Syntax
ts = table2timeseries(t) ts = table2timeseries(t, "RowTimes", time) ts = table2timeseries(t, "SampleRate", sampleRate) ts = table2timeseries(t, "TimeStep", timeStep) ts = table2timeseries(t, "SampleRate", sampleRate, "StartTime", t0) ts = table2timeseries(t, "TimeStep", timeStep, "StartTime", t0)
Arguments
- t
table object
- time
time vector or variable name of table
duration or datetime column vector or string
- timeStep
time step, duration or calendarDuration value
- sampleRate
number of samples per second (Hz), real scalar
- t0
start time, duration or datetime value
- ts
timeseries object
Description
table2timeseries converts a table into a timeseries. The table must have a duration or datetime variable.
If the table has multiple duration and datetime variables, the first variable becomes the row times of timeseries. It is also possible to specify the name of the variable which will become the rowtimes of the timeseries, thanks to 'RowTimes'.
If the table does not contain any time variable, you must use: 'RowTimes', 'TimeStep' or 'SampleRate':
ts = table2timeseries(t, 'RowTimes', time) adds a vector time to the timeseries.
ts = table2timeseries(t, 'TimeStep', timeStep): ts will be a timeseries whose the time vector is generated from the time step timeStep. By default, the first row time is zero seconds and this vector will have the same number of rows as the table t.
ts = table2timeseries(t, 'SampleRate', sampleRate) create a timeseries from a table whose the time vector is generated from the sample rate sampleRate. sampleRate is a real value, number of samples per second. The first value of this time vector is zero seconds and will have the same number of rows as the variable data vectors.
To define the first row time, you must use 'StartTime'.
For more information, see timeseries.
Examples
ts = table2timeseries(t)
Time = datetime(2023, 6, 1:3)'; A = [1; 2; 3]; B = [10; 20; 30]; C = [-10;-20;-30]; t = table(Time, A, B, C, "VariableNames", ["Time", "A", "B", "C"]); ts = table2timeseries(t)
ts = table2timeseries(t, "RowTimes", time) where time is a variable name
Time = datetime(2023, 6, 1:3)'; A = [1; 2; 3]; B = [10; 20; 30]; C = [-10;-20;-30]; Hours = hours(1:3)'; t = table(Time, A, B, C, Hours, "VariableNames", ["Time", "A", "B", "C", "Hours"]); ts = table2timeseries(t, "RowTimes", "Hours")
ts = table2timeseries(t, "RowTimes", time) where time is a datetime vector
Time = datetime(2023, 6, 1:3)'; A = [1; 2; 3]; B = [10; 20; 30]; C = [-10;-20;-30]; t = table(A, B, C, "VariableNames", ["A", "B", "C"]); ts = table2timeseries(t, "RowTimes", Time)
ts = table2timeseries(t, "TimeStep", time)
A = [1; 2; 3]; B = [10; 20; 30]; C = [-10;-20;-30]; t = table(A, B, C, "VariableNames", ["A", "B", "C"]); ts = table2timeseries(t, "TimeStep", hours(1))
ts = table2timeseries(t, "SampleRate", time)
A = [1; 2; 3]; B = [10; 20; 30]; C = [-10;-20;-30]; t = table(A, B, C, "VariableNames", ["A", "B", "C"]); ts = table2timeseries(t, "SampleRate", 0.05)
See also
- table — create a table from variables
- timeseries2table — convert a timeseries into a table
- timeseries — create a timeseries - table with time as index
History
Версия | Описание |
2024.0.0 | Introduction in Scilab. |
Report an issue | ||
<< table2struct | Timeseries/Table | timeseries >> |