Sunteți pe pagina 1din 1
Preprocessing Time Series Data with MATLAB This reference shows common use cases, but is by
Preprocessing Time Series Data with MATLAB This reference shows common use cases, but is by
Preprocessing Time Series Data with MATLAB This reference shows common use cases, but is by
Preprocessing Time Series Data with MATLAB This reference shows common use cases, but is by
Preprocessing Time Series Data with MATLAB This reference shows common use cases, but is by

Preprocessing Time Series Data with MATLAB

This reference shows common use cases, but is by no means comprehensive.

The

icon provides links to relevant sections of the MATLAB ® documentation to learn more.

icon provides links to relevant sections of the MATLAB ® documentation to learn more.

 
Timetable MATLAB datatype designed to organize and work with time series data. Components of a
Timetable
MATLAB datatype designed to organize and work
with time series data.
Components of a Timetable
Create Timetables
tt = timetable(times, var1, var2,
,varN);
(All variables must have the same number
of rows.)
tt = table2timetable(t);
(The first datetime or duration variable in “t”
becomes the row times.)

Timetable Manipulation

 

Data Cleaning

Access Data These return the same array:

 

Smooth Data

Access Data These return the same array:   Smooth Data
Access Data These return the same array:   Smooth Data

tt.Temperature

tt.Temperature B = smoothdata(A,method);

B

= smoothdata(A,method);

tt{:,’Temperature’}

Smooth noisy data with methods:

tt{:,1}

tt{:,1} ‘movmean’,’movmedian’,’gaussian’,

‘movmean’,’movmedian’,’gaussian’,

 

‘lowess’,’loess’,’rlowess’,

 

Add a New Variable

‘rloess’,’sgolay’

 

tt.newVar = zeros(height(tt),1); Change Variable Names

tt.newVar = zeros(height(tt),1); Change Variable Names

Detect Outliers

tt.newVar = zeros(height(tt),1); Change Variable Names Detect Outliers  
 
tt.newVar = zeros(height(tt),1); Change Variable Names Detect Outliers  

tt.properties.VariableNames = newNames; (Names must be valid MATLAB identifiers)

tt.properties.VariableNames = newNames; (Names must be va l i d MATLAB identifiers)
 

TF = isoutlier(A,method);

Identify outliers with methods:

‘median’,’mean’,’quartiles’,

 

Tip: Use matlab.lang.makevalidname to create valid names from potentially invalid names.

‘grubbs’,’gesd’

 
Tip: Use matlab.lang.makevalidname to create valid names from potentially invalid names. ‘grubbs’,’gesd’  

Detect Change Points

Detect Change Points

Resample Data Using Retime

 

TF = ischange(A,method);

tt = retime(tt,newtimes,method);

tt = retime(tt,newtimes,method); Find abrupt changes with methods:

Find abrupt changes with methods:

method is used to fill gaps after retiming, and has the same options as synchronize (see “Merge Timetables”).

‘mean’,’variance’,’linear’

 

Merge Timetables

Synchronize multiple timetables to a common time vector.

tt = synchronize(tt1,tt2,

Synchronizing often results in missing data points (times at which a variable was not measured). synchronize supports several methods for adjust- ing data to fill in gaps:

several methods for adjust- ing data to fill in gaps: Fill: ‘fillwithmissing’,‘fillwithconstant’

Fill: ‘fillwithmissing’,‘fillwithconstant’

Interpolation: ‘linear’,’spline’,’pchip’

Nearest Neighbor: ‘previous’, ‘next’,’nearest’

Aggregation: ‘mean’,’min’,’max’,@func,

Nearest Neighbor: ‘previous’, ‘next’,’nearest’ Aggregation: ‘mean’,’min’,’max’,@func,

Missing Data

 

Big Data

 

Find Missing Values TF = ismissing(tt);

Find Missing Values TF = ismissing(tt); Tall arrays extend MATLAB functions to work on data too

Tall arrays extend MATLAB functions to work on data too big to load into memory.

Fill Missing Values tt = fillmissing(tt,method);

 

Create a “tall” timetable:

 
  % Create a datastore that points to
 

%

Create a datastore that points to

the data ds = datastore(‘*.csv’);

%

 

Replace missing values with values calculated from nearby points with methods:

‘previous’,’next’,’nearest’,

 

%

Create a tall table from the

‘linear’,’spline’,’pchip’

%

datastore

 

t

= tall(ds);

  t = tall(ds);

Remove Rows Containing Missing Values

 

%

Convert to a timetable

 

tt = rmmissing(tt);

 

tt = table2timetable(t);

tt = rmmissing(tt);   tt = table2timetable(t);
 
 
 

© 2018 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders.