Results 1 to 3 of 3

Math Help - Need Help with Function files and Fzero command (Homework problem MATLAB)

  1. #1
    Newbie
    Joined
    Feb 2011
    Posts
    6

    Need Help with Function files and Fzero command (Homework problem MATLAB)

    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:

    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 x percent of its initial value of 10^9 L. The inputs of the second function should be x and 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.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    4
    Awards
    2
    Is this assignment for a grade?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Jenkins View Post
    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:

    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 x percent of its initial value of 10^9 L. The inputs of the second function should be x and 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
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. MATLAB: The cat command
    Posted in the Math Software Forum
    Replies: 4
    Last Post: July 13th 2010, 02:32 PM
  2. Matlab function M-Files
    Posted in the Math Software Forum
    Replies: 1
    Last Post: April 5th 2010, 05:33 AM
  3. MATLAB - Function M-Files
    Posted in the Math Software Forum
    Replies: 6
    Last Post: March 27th 2010, 11:20 PM
  4. Matlab fzero function
    Posted in the Math Software Forum
    Replies: 3
    Last Post: January 8th 2010, 05:30 AM
  5. Matlab, vectors and function files
    Posted in the Math Software Forum
    Replies: 2
    Last Post: August 20th 2009, 02:41 PM

Search Tags


/mathhelpforum @mathhelpforum