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 become irregular. This 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
to check for irregularly sampled data.
data = thingSpeakRead(12397,'NumMin',5,'Fields',4,'outputFormat','timetable');
Data in channel 12397 for the last 60 minutes
is stored in
data as a timetable. Use
to check if the channel data is regularly sampled. If data is irregularly
sampled, then display the time difference.
regularFlag = isregular(data,'Time')
regularFlag = logical 0
if ~regularFlag display(diff(data.Timestamps)) end
4×1 duration array 00:01:01 00:01:01 00:01:00 00:01:02