timeseries.setuniformtime
timeseries: ts = setuniformtime (ts, 'StartTime', start)
timeseries: ts = setuniformtime (ts, 'Interval', step)
timeseries: ts = setuniformtime (ts, 'EndTime', end)
timeseries: ts = setuniformtime (ts, name1, value1, name2, value2, …)
Give a series a uniform time vector.
ts = setuniformtime (ts, …) replaces the time
vector of the series ts by one of evenly spaced times, one per
sample, in its own units; the samples are not moved. The times are
fixed by any one or two of these options, or all three when they
agree, the names matched in any case and a later occurrence overriding
an earlier one:
| Given | Times |
|---|---|
'StartTime' | from start, a step of 1 |
'Interval' | from 0, a step of step |
'EndTime' | from 0 to end |
'StartTime', 'Interval' | from start, a step of step |
'StartTime', 'EndTime' | from start to end, both exact |
'Interval', 'EndTime' | to end, a step of step |
Each value is a finite real scalar in the series’ units, relative to
TimeInfo.StartDate when the series has one. A step of zero gives
equal times. A negative step, a start after the end, or an end below
zero given alone are refused, since the times would run backwards;
MATLAB then empties the time vector and keeps the data. MATLAB also
ignores NaN, which is refused here, and a series of one sample
given equal start and end times, which MATLAB refuses, gets that time.
See also: timeseries.setabstime, tsdata.timemetadata
Source Code: timeseries
setuniformtime spaces the samples evenly without moving them: from a start time, by a step, or up to an end time, in any usable pair.
ts = timeseries ([10; 20; 30; 40], [0; 1; 5; 6]); s = setuniformtime (ts, 'StartTime', 10, 'Interval', 0.5); s.Time'
ans = 10.000 10.500 11.000 11.500
s = setuniformtime (ts, 'StartTime', 0, 'EndTime', 9); s.Time'
ans = 0 3 6 9