Hello I am trying to run the example code for "Calculate and display average humidity" using my channel data. I filled in the blanks: readChannelID humidityFieldID NumMinutes=720 The program returns display(avgHumidity,'Average Humidity') with "NAN" instead of the correct average. I have a free ThingSpeak account but have been following temperature & humidity every hour for the last 9 months. I would also like to store this average value on the same channel on a new field. Can anyone help me? Thank You Apps Matlab Analysis receiving NAN to "Calculate and display average humidity" Is your channel public? If so, can you share the ID and we can have a look. If not, can you share the data from the last 720 minutes in your channel and we can see it? To show the data, you can use the REST API https://api.thingspeak.com/channels/CHANNELID/feeds.json?api_key=APIKEY&munutes=720 or thingSPeakRead data = thingSpeakRead(CHANNELID,ReadKey='channel Read API key', 'outputformat', 'timetable) If you put the thingSpeakRead command in a MATLAB analysis and leave the semicolon off the end, it will show you the output. Thank you. I removed the semicolon to see what was happening. In fact, I am logging 3 fields at time1 and 3 other fields at time2. It's information coming from 2 sensors at 2 different times. Time1 values were sent to fields 1,2,3 at 23:42:50 Friday and Time2 values to fields 4,5,6 at 00:10:37 Saturday. (See example below). Apparently the channel needs all 6 fields at the same time?? Ven 04/03/2022 23:42:50 AT+CIPSEND=0,102 GET https://api.thingspeak.com/update?api_key=1C283SDWBZQ1FP83&field1=8.22&field2=72.61&field3=337 Sam 05/03/2022 00:10:37 AT+CIPSEND=0,103 GET https://api.thingspeak.com/update?api_key=1C283SDWBZQ1FP83&field4=11.81&field5=1.8&field6=505 yes, every entry in the feeds table sets a null response to all fields that arent populated simultaneously. So if you dont send them at the same time, there will be some unexpected effects. We would expect sensors that do not post at the same time to use a seperate channel. That way your field plots will work as expected. OK. I understand. I did it like that to have a centralized view of all data on the same graphset for covenience. It's been working fine like that. The null values are just ignored on the graph. I wanted to do a moving average on one of the fields. I'll do it with my Arduino using a 1st order recursive lowpass filter and put it on an additional field. Thank you. You can use MATLAB visualizations to summarize results from other channels and add that you the other channel, or you can plot multiple channels data on a single plot. You can also use MATLAB to remove the NAN values in the data you have and show the actual average. In that case, the cleanest way seems to be: Create 2 channels for my 2 sensors. Create a 3rd channel for my average results on channel 2, field2. Plot the 3 channels on a single plot. Since channel 1 will not be synchronized with channel 2 and 3, will the single plot still work? Thank you for your help! Yes you can read from both channels to create your display. You will have to be a little thoughtful about how you combine the data. Here is an example where you read data from three different days and plot it on the same axis. You can also use tiledlayout to create multiple axis plots in the same figure. To regularly create the average, you can use timecontrol to schedule the code. If you become channel constrained, you can calculate the average when you build the plot instead of writing it to a new channel. You wont need to save the average results since they are dependant on the existing data. Another posibility wopuld be to write sensor 1 and two measurements to the third channel at the same time. You can use retime to syncronize the time stamps (if you read the data into a timetable). Then the standard field plots in the third, derived channel, will work. This depends on how far apart in time the readings are. To fill in the data, you could use the last value of sensor 1 when sensor 2 has a reading, or the moving average. there are name value pairs in the retime function to do that. MATLAB gives you lots of choices. Wow! An impressive toolset! You've opened up a new door for me to discover the Matlab Wonderland! Thanks! So, I finally chose the solution which economizes rework on my 2 Arduino prototype programs. I used the example in Matlab analysis, "Replace missing values in data". I analyzed my 6 channelID 1418147 fields to get the latest 1 (or 10) non NAN entries, calculated the mean on 10 values of my pool water level, then posted the time resynchronized 7 fields to channelID 1722490. I perform the analysis slightly more frequently than I do for my fastest sensor so not to skip any data. It works like a charm! Thanks for your help! I appreciate you letting us know and I'm really glad to hear it worked for you! If you have time to check in here at the community again, we love for you to pass on some of your new ThingSpeak and MATLAB skills. matlab analysis average humidity nan same channel apps