Resample or aggregate timetable data in the Live Editor
The Retime Timetable task lets you interactively change the row times of a timetable and then resample or aggregate the data in its variables. The task automatically generates MATLAB® code for your live script.
Using this task, you can:
Interpolate data values at new row times.
Aggregate data into time bins (for example, to create a timetable containing quarterly means from monthly data).
Remove rows that have duplicate row times.
Make an irregular timetable into a regular one by specifying a uniform time step or sample rate.
To add the Retime Timetable task to a live script in the MATLAB Editor:
On the Live Editor tab, select Task > Retime Timetable.
In a code block in the script, type a relevant keyword, such as
retime
or timetable
. Select Retime
Timetable from the suggested command completions.
Input timetable
— Name of timetableSpecify the name from a list of all the nonempty timetables that are in the workspace.
Selection method
— Method for specifying row timesSpecify the method for calculating new row times of the timetable.
Time step
— Length of time between consecutive
regularly spaced row times.
Sample rate
— Sample rate or frequency for regularly
spaced row times.
Times from workspace
— Workspace variable that is a
vector of datetime
or duration
values. The
times in the vector replace the row times of the timetable. The times need not be
regularly spaced.
General rule
— Rule for adjusting data valuesSpecify the rule for resampling or aggregating values in the variables of the timetable. The rule applies to all variables unless exceptions are specified.
Fill values
— Fill gaps with missing data indicators
or a constant value.
Interpolate data
— Interpolate data values to the new
row times. For example, resample data measured at 100 Hz to 200 Hz.
Aggregate data
— Aggregate data into time bins. For
example, calculate a daily mean from data values measured at every hour.
Exceptions
— Different rule or rules for adjusting specified variablesClick the Add button. Then specify a timetable variable from the drop-down list of variable names that appears.
To adjust the data in the specified variable, select a rule from the drop-down list of rules to the right of the variable name. The rule for the exception can differ from the general rule.
To specify exceptions for other timetable variables, click the + button to the right of the first exception. New drop-down lists of variable names and rules appear below the previous exception.