| MATLAB® | ![]() |
ts = addevent(ts,e)
ts = addevent(ts,Name,Time)
ts = addevent(ts,e) adds one or more tsdata.event objects, e, to the timeseries object ts. e is either a single tsdata.event object or an array of tsdata.event objects.
ts = addevent(ts,Name,Time) constructs one or more tsdata.event objects and adds them to the Events property of ts. Name is a cell array of event name strings. Time is a cell array of event times.
Create a time-series object and add an event to this object.
%% Import the sample data
load count.dat
%% Create time-series object
count1=timeseries(count(:,1),1:24,'name', 'data');
%% Modify the time units to be 'hours' ('seconds' is default)
count1.TimeInfo.Units = 'hours';
%% Construct and add the first event at 8 AM
e1 = tsdata.event('AMCommute',8);
%% Specify the time units of the time
e1.Units = 'hours';View the properties (EventData, Name, Time, Units, and StartDate) of the event object.
get(e1)
MATLAB software responds with
EventData: []
Name: 'AMCommute'
Time: 8
Units: 'hours'
StartDate: ''
%% Add the event to count1
count1 = addevent(count1,e1);An alternative syntax for adding two events to the time series count1 is as follows:
count1 = addevent(count1,{'AMCommute' 'PMCommute'},{8 18})timeseries, tsdata.event, tsprops
![]() | addCause (MException) | addframe | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |