Clear Filters
Clear Filters

How to use Thingspeak to return just data and not timestamp

5 views (last 30 days)
I am wanting to analyse data from a Thingspeak channel but using Thingspeakread is is returning the data and the timestamp which gets shown as NaN. How can I just get the last data points?
Thanks
David

Answers (1)

Garv Agarwal
Garv Agarwal on 19 Jun 2023
Hi David,
From my understanding, when you read data using thingSpeakRead, timestamps get returned along with data while you only require the data and you can't seem to get rid of the timestamps. This happens when the OutputFormat value in the thingSpeakRead function is set to 'timetable'.
There are two ways to fix this-
1. You can use the 'matrix' output format if you don't require column labels and your data is made up of only numeric values-
data = thingSpeakRead(channelID,OutputFormat='matrix');
2. If your data contains a mix of numeric and non-numeric data or you require column labels then you can use the 'table' output format-
data = thingSpeakRead(channelID,OutputFormat='table');
and then remove the first column,
data=data(:,2:end);
For more details, you can refer to the thingSpeakRead documentation https://in.mathworks.com/help/thingspeak/thingspeakread.html

Categories

Find more on Read Data from Channel in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!