Get average water flow for every 15min between 1am and 5am of each day

1 回表示 (過去 30 日間)
CHARLES SANSON
CHARLES SANSON 2020 年 4 月 17 日
コメント済み: CHARLES SANSON 2020 年 4 月 19 日
Hi,
I want to calculate the average water flow every 15 mins between 1am and 5am everyday on my channel data.
I need to know if a pump is running during these hour when it shouldn't be.
I have the average calculation working with code below but I cannot find how to only run this on data between 1am and 5am.
any help would be much appreciated.
waterFlow = thingSpeakRead(readChannelID,'Fields',WaterFlowFieldID,'NumMinutes',15,'ReadKey',readAPIKey);
avgwaterFlow = mean(waterFlow);
display(avgwaterFlow,'Average Water Flow');

回答 (2 件)

Andreas Bernatzky
Andreas Bernatzky 2020 年 4 月 17 日
Hey Charles,
the easiest approach in my opinion is the following.
keep in mind this is pseudoCode (have no matlab at the moment to test):
actualTime = datestr(now,'HH:MM:SS.FFF'))
if(1 am < actualTime && 5am > actualTime)
% do something
end
I will send you the correct code implementation later.
Greets
Andreas

Steven Lord
Steven Lord 2020 年 4 月 17 日
Read in both the water flow data and the date and time data (perhaps by reading your data in as a timetable.) Call hour on the date and time data stored as a datetime array and use that to select the appropriate elements of your water flow data.
  1 件のコメント
CHARLES SANSON
CHARLES SANSON 2020 年 4 月 19 日
Hi Steven,
Thanks for you reply.
I have created a timetable with the code below but I am having trouble with the second part of your suggestion. Would you be able to help with the code for the second part of your suggestion?
Sorry I am relativly new to this and seem to be going around in circles with the documentation.
data = thingSpeakRead(123456,'Fields',humidityFieldID, OutputFormat','TimeTable','ReadKey',readAPIKey)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by