Originally Posted by

**Jenkins** The problem reads like so:

Using estimates of rainfall, evaporation, etc. The town engineer developed the following model for the amount of water in the town reservoir as a function of time:

$\displaystyle V(t) = 10^9 + 10^8(1-e^{-t/100}) - rt$

where V is water volume in liters, t is time in days, and r is the towns consumption rate in liters per day. Write two user defined functions. The first function should define V(t) for use with the *fzero* function. The second function should use *fzero* to compute how long it will take for the water to decrease to $\displaystyle x$ percent of its initial value of $\displaystyle 10^9$ L. The inputs of the second function should be $\displaystyle x$ and $\displaystyle r$.

to be totally honest I don't have the foggiest of an idea on where to start. I'm not looking for anyone to hand me the answer, I just want to be pointed in the right direction.

A basic function definition will look something like:

Code:

function rv=FnName(x,y,z)
u=x+y;
rv=0;
if u>0
rv=x+y+z^2;
else
rv=7;
end

The return value can be an array object, as can the arguments. The function needs to be placed in a .m file with the same name as the function on on the Matlab search path (IIRC the editor will offer to add the location to the search path when you save the file).

CB