setuniformtime
Replaces the time vector of a timeseries with evenly spaced times.
Category: Language Fundamentals > Data Types
Syntax
ts = setuniformtime(ts, 'StartTime', t0, 'Interval', dt)
Sets times t0, t0+dt, t0+2*dt, ....
ts = setuniformtime(ts, 'StartTime', t0, 'EndTime', t1)
Spreads the samples evenly between t0 and t1.
Description
Only the time vector is rewritten; the data values keep their order. Because a uniform series stores just the start and the interval, it uses less memory than one with an explicit time vector.
Input arguments
'StartTime'- Time of the first sample.
'Interval'- Spacing between samples.
'EndTime'- Time of the last sample.
Output arguments
ts- The series with the new, uniform time vector. The data are unchanged.
Example
ts = timeseries([1 2 3]', [0 1 2]);
ts = setuniformtime(ts, 'StartTime', 10, 'Interval', 2);
ts.Time'
Output
ans = 1×3
10 12 14