How to get Current tenperature?

So i found this code and modified it a bit to show all tempertures in the day.
function weathertest2
clc
readChannelID = 12397;
temperatureFieldID = 4;
readAPIKey = '';
[tempF,timeStamp] = thingSpeakRead(readChannelID,'Fields',temperatureFieldID,'numDays',1,'ReadKey',readAPIKey);
[maxTempF,maxTempIndex] = max(tempF);
[minTempF,minTempIndex] = min(tempF);
timeMaxTemp = timeStamp(maxTempIndex);
timeMinTemp = timeStamp(minTempIndex);
display(tempF,'Temperature');
display(maxTempF,'Maximum temperature for the past 24 hours is');
display(minTempF,'Minimum temperature for the past 24 hours is');
display(timeMaxTemp,'Max time stamp');
display(timeMinTemp,'Min time stamp');
end
But I want this code to be able to tell me the current temperture now (or the minute I asked) is there a way to show that?
Thank you

Respuestas (1)

darova
darova el 18 de Mzo. de 2020
Use interp1
t0 = input('Enter time:\n');
if min(timeStamp)<t0 && t0<max(timeStamp)
temp0 = interp1(tempF,timeStamp,t0);
disp('temperature is')
temp0
else
disp('Wrong time')
end

5 comentarios

Rainaire Hansford
Rainaire Hansford el 15 de Abr. de 2020
Well How should i write time
darova
darova el 15 de Abr. de 2020
Write where to?
Rainaire Hansford
Rainaire Hansford el 15 de Abr. de 2020
you have to = input(......
How should I write the time? I tried 05:24:00 or format like it but it keeps coming up with error.
"Undefined function or variable 'timeStamp'."
darova
darova el 15 de Abr. de 2020
Try string format
s = input('enter the time','s');
num = datenum(s);
Rainaire Hansford
Rainaire Hansford el 15 de Abr. de 2020
Yeah that not working either. At the same time im not sure what num is for?

Iniciar sesión para comentar.

Categorías

Más información sobre Just for fun en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 18 de Mzo. de 2020

Comentada:

el 15 de Abr. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by