MATLAB Answers

How to calculate data with price rate for water consumption.

23 ビュー (過去 30 日間)
Aman Kumar
Aman Kumar 2020 年 5 月 17 日
回答済み: Christopher Stapels 2020 年 5 月 18 日
I am looking for a code for matlab analysis of my data, I want to calculate water bill for every 100 litre=1USD, for 1 month. So that the user can get total water consumption bill at the end of the month. Please help.

  7 件のコメント

表示 4 件の古いコメント
Aman Kumar
Aman Kumar 2020 年 5 月 18 日
Thanks it worked, but i didn't got the requided notification message. I needed the data of total water used and bill amount. Here is the code, please check if i did something wrong.
% Enter your MATLAB Code below
% Read Output Water Quantity over the past month from a ThingSpeak channel and write
% the average to another ThingSpeak channel.
% Channel 1035265 contains data from the MathWorks water supply station, located
% in Natick, Massachusetts. The data is collected once every day. Field
% 3 contains output liquid quantity data.
% Channel ID to read data from
readChannelID = 1035265;
% Output Liquid Quantity Field ID
outputliquidqantityFieldID = 3;
% Channel Read API Key
% If your channel is private, then enter the read API Key between the '' below:
readAPIKey = '';
% Get Output Liquid Quantity data for the last 30 days from the MathWorks water supply
% station channel. Learn more about the THINGSPEAKREAD function by going to
% the Documentation tab on the right side pane of this page.
meter_reading = thingSpeakRead(readChannelID,'Fields', outputliquidqantityFieldID,'NumDays',1,'ReadKey',readAPIKey);
% Calculate the Cost
Billing_cost = 5* (meter_reading/1000);
display(Billing_cost,'Total Billing Cost (INR)');
% Start by setting the channel ID and Alert key. All alert key start with TAK.
data = thingSpeakRead(1035265,"NumDays", 1);
Water = sum(data(:, 2));
apiKey = 'TAK1S83KIQN0BBLNS';
alertURL = "https://api.thingspeak.com/alerts/send";
options = weboptions("HeaderFields", ["ThingSpeak-Alerts-API-Key", apiKey ]);
alertBody = sprintf("The Water consumption bill is", 5* (meter_reading/1000));
alertSubject = sprintf(" Water consumption exceeded 100 kl!");
if Water >= 100
webwrite(alertURL, "body", alertBody, "subject", alertSubject, options);
end
Aman Kumar
Aman Kumar 2020 年 5 月 18 日
I need the message as (The water consumption bill is, 5usd" for 1200kl or any amount value that the user consumed. Please Help

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

採用された回答

Christopher Stapels
Christopher Stapels 2020 年 5 月 18 日
This sounds like a very interesting project. I wonder what sensor you are using to track the water consumption.
It sounds like you need help with the sprintf function. This line seems to be missing a format specifier.
alertBody = sprintf("The Water consumption bill is", 5* (meter_reading/1000));
Have a look at the documentation for sprintf.

  0 件のコメント

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

その他の回答 (0 件)

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by