MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

indicators. For instance, retime fills gaps in numeric variables with NaN values, and gaps
in the categorical variable with undefined elements.


Station1Daily = retime(Station1,'daily')


Station1Daily=7×5 timetable
Date Tmax Tmin PrecipTotal WXEvent




04-May-2017 60 44 0.2 Hail
05-May-2017 62 45 0 None
06-May-2017 NaN NaN NaN
07-May-2017 NaN NaN NaN
08-May-2017 56 40 0 None
09-May-2017 59 42 0.15 Thunder
10-May-2017 60 45 0 None


If you specify a method when you call retime, it uses the same method to fill gaps in
every variable. To apply different methods to different variables, you can call retime
multiple times, each time indexing into the timetable to access a different subset of
variables.


However, you also can apply different methods by specifying the VariableContinuity
property of the timetable. You can specify whether each variable contains continuous or
discrete data. Then the retime function applies a different method to each timetable
variable, depending on the corresponding VariableContinuity value.


If you specify VariableContinuity, then the retime function fills in the output
timetable variables using the following methods:



  • 'unset' — Fill in values using the missing data indicator for that type (such as NaN
    for numeric variables).

  • 'continuous' — Fill in values using linear interpolation.

  • 'step' — Fill in values using previous value.

  • 'event' — Fill in values using the missing data indicator for that type.


Specify that the temperature data in Station1 is continuous, that PrecipTotal is step
data, and that WXEvent is event data.


Station1.Properties.VariableContinuity = {'continuous','continuous','step','event'};
Station1.Properties


Retime and Synchronize Timetable Variables Using Different Methods
Free download pdf