Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Team

I have this code below and my channel is set to public and now i am getting unrecognized function or variable using 'avg_temperature'. Anyone who can help me with this issue?

What I have tried:

data = thingSpeakRead(929272, "NumMinutes", 100);
aveTemp = mean(data(:,7));
apiKey = '****';
alertURL = "https://api.thingspeak.com/alerts/send";
options = weboptions("HeaderFields",["ThingSpeak-Alerts-API-Key", apiKey]);
alertBody = sprintf("The temperature is %0.2fF.", aveTemp);
if avg_temperature > 60.0
    webwrite(alertURL, "body", alertBody, "subject", alertSubject, options);
end
Posted
Updated 12-Jan-20 22:32pm
Comments
Richard MacCutchan 13-Jan-20 4:32am    
The message is perfectly clear. You are referring to the variable avg_temperature, but you have not defined it anywhere.

1 solution

Most probably, replace avg_temperature with aveTemp; but it's just a wild guess.

If this does not solve the issue, then you will have to explain with more details where and how you did define the avg_temperature variable. If you have copied part of this code from somewhere without trying to understand what it does, then you may also have to rethink the way you are learning and experiencing.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900