timeseries.addevent
timeseries: ts = addevent (ts, event)
timeseries: ts = addevent (ts, name, time)
Add events to a series.
ts = addevent (ts, event) appends the
tsdata.event object or array event to the Events of
the series ts, in the order given.
ts = addevent (ts, name, time) appends an
event named name at time. name is a character vector
or a string scalar, and time a real number in the series’ units,
counted from its TimeInfo.StartDate when it has one; for a
series with a start date time may also be a date, as text or a
datetime. For several events, name is a cell array of
character vectors or a string array, and time a cell array, a
numeric vector or a string array of as many times.
Events are kept in the order they are added, not sorted; an event whose name and time match one already held is not added again, while the same name at another time is.
A date on a series with no start date is refused, since the series has
no calendar to place it on; MATLAB accepts it and reads the event as
time 0. A NaN time is refused too.
See also: timeseries.delevent, tsdata.event, timeseries.gettsatevent
Source Code: timeseries
An event marks a time in a series, by name. It may be given as a tsdata.event object, which can carry data of its own.
ts = timeseries ((1:10)', 0:9);
ts = addevent (ts, 'start', 2);
e = tsdata.event ('stop', 7);
e.EventData = 'valve closed';
ts = addevent (ts, e);
{ts.Events.Name; ts.Events.Time}
ans =
2x2 cell array
{'start'} {'stop'}
{[ 2]} {[ 7]}