Calculate and Display Average Humidity

Hello,
iam trying with the above template to calculate average weight (field4) of channel 2165217 (public),
it works on field 1 but not on field 4 that i want.Both fields are send as string.
Error is :
Error using Calculate and display average humidity (line 21)
Unrecognized table variable name 'x'.
What is wrong?,thank you.

5 Comments

Share your code. Without seeing your code, it’s hard to provide a more specific solution.
% Read humidity over the past hour from a ThingSpeak channel and write
% the average to another ThingSpeak channel.
% Channel 12397 contains data from the MathWorks weather station, located
% in Natick, Massachusetts. The data is collected once every minute. Field
% 3 contains humidity data.
% Channel ID to read data from
readChannelID = 2165217;
% Humidity Field ID
humidityFieldID = 4;
% Channel Read API Key
% If your channel is private, then enter the read API Key between the '' below:
readAPIKey = '';
% Get humidity data for the last 60 minutes from the MathWorks weather
% station channel. Learn more about the THINGSPEAKREAD function by going to
% the Documentation tab on the right side pane of this page.
humidity = thingSpeakRead(readChannelID,'Fields',humidityFieldID,'NumDays',1,'ReadKey',readAPIKey);
% Calculate the average humidity
avgHumidity = mean(humidity);
display(avgHumidity,'Average Humidity');
The error is happenning while parsing, in the 'thinkSpeakRead.m' file. It was unable to parse the server response, probably server response is not as expected. First you have pinpoint the exact problem right, Maybe the response format is updated.
respone is the same error,it works only with field 1(string) and field 6 (integer)
Hi PANOS,
The channel 2165217 you mentioned does not have any data as of now. Can you please check the channel number and also provide the code you are using so that I can reproduce the issue. I will be waiting for your response.

Sign in to comment.

Answers (0)

Categories

Find more on Weather and Atmospheric Science in Help Center and File Exchange

Products

Tags

Asked:

on 27 May 2024

Commented:

on 7 Aug 2024

Community Treasure Hunt

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

Start Hunting!