Bug in average calc in API read? (Thingspeak)

조회 수: 1 (최근 30일)
Robert Mollik
Robert Mollik 2020년 12월 31일
댓글: Robert Mollik 2021년 1월 1일
Hi,
when I request the average data of a feed using the api call, I sometimes get unplausible values. My channel contains one field for special purpose, that is being updated asynchronously. It seems like, when that field contains data (while the others contain NULL), the average calculation is messed up. I believe that the average calculation interprets NULL as 0.
Is this a bug or a feature?
Thanks, Robert

답변 (1개)

Vinod
Vinod 2020년 12월 31일
A NULL or non-numeric value in a field is "Not a Number" and will be treated as a zero in the averaging in the implementation on ThingSpeak. Typically when I have seen this to be an issue is when some fields in a channel are updated at different rates than other fields, resulting in the fields having NULLs in them when a value was not specified.
If you are looking to ignore the NULL/non-numeric values in the mean calculation, my recommendation is to use MATLAB. Use the thingSpeakRead function to pull data into MATLAB and then the mean function to generate the average. Remember to set the nanflag parameter to omitnan.
  댓글 수: 1
Robert Mollik
Robert Mollik 2021년 1월 1일
Hi Vinod,
thanks for the quick answer. Then I will either do it in MATLAB or just remove the asynchronous field.
Is there any plan to add the omitnan flag in the thingspeak api call in the future?
Thanks, Robert

댓글을 달려면 로그인하십시오.

커뮤니티

더 많은 답변 보기:  ThingSpeak 커뮤니티

카테고리

Help CenterFile Exchange에서 Read Data from Channel에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by