# How to calculate data with price rate for water consumption.

18 views (last 30 days)
Aman Kumar on 17 May 2020
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.

David Stacer on 18 May 2020
Aman Kumar on 18 May 2020
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
% Output Liquid Quantity Field ID
outputliquidqantityFieldID = 3;
% If your channel is private, then enter the read API Key between the '' below:
% Get Output Liquid Quantity data for the last 30 days from the MathWorks water supply
% the Documentation tab on the right side pane of this page.
% Calculate the Cost
display(Billing_cost,'Total Billing Cost (INR)');
Water = sum(data(:, 2));
apiKey = 'TAK1S83KIQN0BBLNS';
alertSubject = sprintf(" Water consumption exceeded 100 kl!");
if Water >= 100
end
Aman Kumar on 18 May 2020
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 on 18 May 2020
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.
Have a look at the documentation for sprintf.

R2020a

### Community Treasure Hunt

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

Start Hunting!