Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with this matlab project. I need Function FIND_TANK (ASAP) and then

ID: 3554294 • Letter: I

Question

I need help with this matlab project. I need Function FIND_TANK (ASAP) and then function FIND_FAMILY(can wait). Thanks

Rainwater Project

Introduction

The population of India is in the midst of a water shortage. The number of people with access to adequate water is decreasing as pollution makes some water sources unsafe for consumption, and the increasing population adds strain on the already limited water supplies. As a result, many people are turning to rooftop water collection systems to gather and store rainwater. They use a tank that catches rainwater from the roof and stores it for household use throughout the year.

(Image from: http://www.circleofblue.org/waternews/2010/world/india- cities-focus-on-rainwater-harvesting-to-provide-clean-drinking-water/)

Your task in this project is to create a MATLAB program to design a rainwater collection system for a region in India. India is subject to a severe monsoon season, where the majority of the rainfall may fall in the 3-4 months of summer.

The user has two primary questions they need your program to answer for them:

1. "Since I know my family and roof size, what is the smallest tank volume I need so I can collect enough water to support my family for 36 months?"

2. "I have a tank of a specific size. How many people can my tank support for a full 36 months?"

Page 2 of 9

What does your program need to do?

Your program will start from one function titled RUN_RAINWATER, which will call one of two other functions, either FIND_TANK or FIND_FAMILY, depending on which question the user wants to answer.

When the program begins, it will ask the user which question they want to answer, or if they want to simply quit. If the user selects a question to answer, then RUN_RAINWATER will need to call the necessary function.

Question Path 1 requirements (FIND_TANK)

When this function is called, the user will need to input the number of people in their family and the size of their roof (m2). The function will then need to calculate the minimum tank size (Liters) necessary to support the family for 36 months. When you return this tank volume to the user, your code will also generate a single plot of the amount of water in the tank at the end of each month for the full 36 months.

If the family ever runs out of water during that time (perhaps you have an area with very low rainfall), then you need to also keep track of how much additional water the family will need to collect from another source, for each month. These values will also need to be included in the final plot.

Question Path 2 requirements (FIND_FAMILY)

When this function is called, the user will need to input the area of their roof (m2) and the volume of their tank (L). Using these values, the program needs to determine the maximum number of people that the given tank and roof can support for a full 36 months. The program will return this value to the user and generate a plot of the amount of water in the tank at the end of each month, using that calculated family size.

If it isn't possible to support anyone consistently for 36 months with the given tank and roof size, then your program will need to (1) inform the user that no one can be supported with the current parameters, and (2) assuming a family size of one person, generate a plot of both the amount of water in the tank at the end of each month and the amount of additional water each month that the person will need to collect from some other source to meet their needs.

After the program answers either question 1 or 2 for the user (calculates FIND_TANK or FIND_FAMILY), the program will need to ask the user if they want to calculate something else, or if they want to quit. If the user wants to recalculate, they will again need to select which question they want to answer, and the code will continue. Page 3 of 9

Requirements of the Code

There are specific requirements for the code and program that you will need to meet for this project.

Rainfall and water use data

When performing your calculations, your program will need to know the average water use per person in India, as well as the average rainfall per month of your region. The program will get this information from a file titled variables.mat which will contain two variables: rainfall and wateruse. The rainfall variable will be a 1x12 vector containing the average rainfall (mm) per month in each respective month. For example, rainfall(1) should return the average rainfall for the month of January. The variable wateruse will be a single value containing the average water use in Liters per person per day (L/person/day). You will need to create this variables.mat file to be submitted with your code.

Your program should not have any of this information "hard-coded" into it. This means that you can't type the rainfall vector or wateruse value directly into your m-files, they need to be retrieved by loading variables.mat. You may need to look up how to use the .mat file format in Matlab.

Units

All of your units for this program need to be in metric units.

? rainfall: mm/month

? wateruse: L/person/day

? Roof area: m2

? Tank size: L

For Question Path 2 it's important to remember that you cannot have a fraction of a person.

m-file Setup

You will have a minimum of 3 function m-files: RUN_RAINWATER, FIND_TANK, and FIND_FAMILY.

RUN_RAINWATER will be the function that your user will call to start the program. The functions FIND_TANK and FIND_FAMILY will be called by the code within Page 4 of 9

RUN_RAINWATER, depending on which Question Path the user selects. Any helper functions used by these functions should be included at the end of their respective m-files.

You cannot have any additional m-files except in the case of Extra Credit portions. If you include extra credit sections, you need to modify your RUN_RAINWATER so the extra credit portions are included in the options for the user to choose from.

Your m-files must all be function m-files. For example, you would set up the first line of your RUN_RAINWATER function like this:

function RUN_RAINWATER()

As you can see, there are no inputs within the () of this function. See the I/O Requirements section for an explanation of the input and output requirements for this program.

A note about Modularity

When designing your program it helps to break the problem into smaller pieces. If you will have one calculation being performed repetitively, consider creating a new function for this calculation. If you place "helper functions" at the bottom of an m-file

Explanation / Answer

function [V]= Findvolume (N,A)
prompt='What is the number of member in your family '
result=input(prompt);
N=result;
prompt='What is the area of the roof in m^2 '
result1=input(prompt)
A=result1;
sum=0;
water_needed=zeros(1,36);
month=[31 28 31 30 31 30 31 31 30 31 30 31];
matObj = matfile('variables.mat');
s=load('variables.mat');
%rainfall=struct2d(rainfall)
[maximum,I]=max([s.rainfall]);

%calculating for a year hence rainfall is periodic about a year

[mnthlyrf I]=sort(s.rainfall,'descend')
um=month(I); %um=updated month
for i=1:12
    for j=1:2
        um(i+12*j)=um(i);
        mnthlyrf(i+12*j)=mnthlyrf(i);
    end
end
for i=1:36

    water_demand(i)=s.wateruse/1000*N*um(i);
    water_available(i)=mnthlyrf(i)*A/1000;
    water_saved(i)=-water_demand(i)+water_available(i)+sum;
    if water_saved(i) <0
        water_needed(i)=-water_saved(i);
        water_saved(i)=0;
    else water_needed(i)=0;
    end
    sum=water_saved(i);
end
    V=max(water_needed);
    disp('maximum voulme of tank needed in m^3');
   disp(V)
   disp(um)
   x=1:36
plot(x,water_saved,'r',x,water_needed)
xlabel('month')
ylabel('volume')