extractevents
Extract an event table from rows of a timetable.
📝Syntax
ET = extractevents(TT, rows)
ET = extractevents(TT, labels)
ET = extractevents(..., Name, Value)
[ET, TT2] = extractevents(...)
📥Input Arguments
Parameter Description
TT Input timetable.
rows Rows of TT: row numbers, logical mask, row times (datetime or duration), timerange or ':'.
labels categorical vector with one element per row of TT: the defined elements are the labels of the events, the rows with <undefined> are not events.
Name, Value EventLabels, EventLengths, EventEnds: values (scalar or one per event); EventLabelsVariable, EventLengthsVariable, EventEndsVariable: variable of TT holding them; EventDataVariables: variables of TT copied to the event table; PreserveEventVariables: true to keep these variables in TT2 (default false).
📤Output Arguments
Parameter Description
ET Event table: the row times of the selected rows and the event variables.
TT2 Copy of TT without the variables copied to ET, unless PreserveEventVariables is true.
📄Description

extractevents creates an event table from rows of a timetable. Only the variables named by the options are copied: the event lengths or ends variable first, then the event labels variable, then the data variables, then the variables made from the EventLabels, EventLengths and EventEnds values.

An event variable cannot also be listed in EventDataVariables. PreserveEventVariables requires at least one variable option and the second output.

To read the event table attached to a timetable, use TT.Properties.Events.

💡Examples
TT = timetable(seconds([1; 2; 3; 4]), [10; 20; 30; 40], ["a"; "b"; "c"; "d"], 'VariableNames', {'A', 'L'});
ET = extractevents(TT, [2 4], 'EventLabelsVariable', 'L')
[ET, TT2] = extractevents(TT, timerange(seconds(2), seconds(4)), 'EventDataVariables', 'A')
TT = timetable(seconds([1; 2; 3; 4]), [10; 20; 30; 40], 'VariableNames', {'A'});
ET = extractevents(TT, categorical(["start"; ""; ""; "stop"]))
🔗See Also
synceventseventtabletimetable
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub