Identify Irregularly Sampled Data
This example shows how to identify irregularly sampled data in a ThingSpeak™ channel. You can apply data preprocessing and data analytics algorithms on regularly sampled data. Hence, it is important to be notified when the time period between measurements becomes irregular. This irregularity could indicate a sensor failure or other issues with the measurement setup. Irregularly sampled data also leads to loss of data for subsequent analytics.
ThingSpeak channel 12397 contains data from the MathWorks® weather station, located in Natick, Massachusetts. The data is collected once every minute. Field 4 of the channel contains air temperature data. Read the air temperature data from channel 12397 using the
thingSpeakRead function to check for irregularly sampled data.
data = thingSpeakRead(12397,'NumMin',5,'Fields',4,'outputFormat','timetable');
Check for Irregularly Sampled Data
Data in channel 12397 for the last 60 minutes is stored in data as a timetable. Use
isregular function to check if the channel data is regularly sampled. If the data is irregularly sampled, then display the time difference.
regularFlag = isregular(data,'Time') if ~regularFlag display(diff(data.Timestamps)) end