How do I read the last 3 Thinkspeak channel statuses into an array?
Mostrar comentarios más antiguos
I am currently running a ThingSpeak Maltlab analysis that reads the latest channel status and acts on it. I am using this code, which works fine:
url='https://api.thingspeak.com/channels/mychan/feeds/last.json?api_key=mykey&status=true';
lastData=webread(url);
status = [lastData.status];
I am trying to figure out how to change this to read the last 3 channel statuses and put them into an array like status(i) where i goes from 1-3? This url returns the 3 statuses I want:
url = https:'//api.thingspeak.com/channels/mychan/status.json?api_key=mykey&results=3'
But I can't figure out how to get them into an array to work with. Does anyone know how to do this? Thanks.
2 comentarios
Image Analyst
el 9 de Mayo de 2025
Editada: Image Analyst
el 9 de Mayo de 2025
Does anything in the url change when you "read the last 3 channel"? Like mychan or something? Or do you call the same URL, just in a loop after a time delay? Like
for timePoint = 1 : 3
lastData=webread(url);
status(timePoint) = lastData.status;
pause(2); % Pause 2 seconds.
end
What is the lastData variable? What does this show
lastData
whos lastData
Chris
el 9 de Mayo de 2025
Respuesta aceptada
Más respuestas (0)
Comunidades de usuarios
Más respuestas en ThingSpeak Community
Categorías
Más información sobre Write Data to Channel en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!