ThingspeakRead returns cell array

2 ビュー (過去 30 日間)
Dimitris Lymperis
Dimitris Lymperis 2020 年 12 月 17 日
移動済み: Christopher Stapels 2024 年 1 月 5 日
I am using the following commands in a script to retrieve the records from the last 5 minutes of two diffirent temperature sensors.
Temp_1 = thingSpeakRead(readChannelID_1,'Fields',Temperature_1_FieldID,'NumMinutes',5,'ReadKey',readAPIKey_1,'OutputFormat','timetable')
Temp_2 = thingSpeakRead(readChannelID_2,'Fields',Temperature_2_FieldID,'NumMinutes',5,'ReadKey',readAPIKey_2,'OutputFormat','timetable')
Some times i get a good one timetable with double values (rarely) for temperature and some other time i get a cell array with the following format.
Timestamps Temperature_2
____________________ _____________
17-Dec-2020 23:16:00 {'nan' }
17-Dec-2020 23:16:16 {'16.10000'}
17-Dec-2020 23:16:31 {'16.10000'}
17-Dec-2020 23:18:52 {'16.10000'}
17-Dec-2020 23:19:09 {'nan' }
17-Dec-2020 23:19:25 {'16.10000'}
17-Dec-2020 23:19:41 {'16.10000'}
17-Dec-2020 23:20:28 {'16.10000'}
17-Dec-2020 23:20:44 {'16.10000'}
why does it happen and how can i get only the double values?

回答 (1 件)

Christopher Stapels
Christopher Stapels 2020 年 12 月 21 日
移動済み: Christopher Stapels 2024 年 1 月 5 日
thingSpeakRead is returning a cell array when there is text in the fields. When you are reading the 'nan' values, ThingSpeak is giving you a cell array. Try reading a section where there are no 'nan' values.
Are you writing to the same channel with two different devices? If so, that would explain the empty entries. We reccomend one channel per device.
By the way, you can read both fields at once if you use 'fields', [Temperature_1_FieldID Temperature_2_FieldID].

コミュニティ

その他の回答  ThingSpeak コミュニティ

カテゴリ

Help Center および File ExchangeVisualize Data についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by