Results 1 to 3 of 3

Math Help - Modeling Function Difficulty

  1. #1
    Newbie
    Joined
    Nov 2008
    Posts
    2

    Modeling Function Difficulty

    Hello I'm doing a simplified model of a bouncing ball and I am having trouble getting my function DISTANCE to output values for a range of 0:N. I can make it output a single correct value, but not values of 0:N-1...0:0 etc. I have been stuck on this for HOURS. If someone could offer some input on this that would be spectacular.
    My functions are defined as: H0=Initial Height, R=Rebound coefficient, and N=NUmber of bounces. Function HEIGHT finds the height after N bounces, and DISTANCE finds the total vertcial distance. I use (5, .4, [0:7]) to test.

    function [HNN]=HEIGHT(H0, R, N)
    HNN=H0.*R.^N;

    function [TVD]=DISTANCE(H0, R, N)
    [HNN]=HEIGHT(H0, R, N);
    INITIAL=H0;
    FINAL=HNN(length(HNN));
    MIDDLE=HNN(1,2: (length(HNN)-1));
    TVD=FINAL+INITIAL+sum(MIDDLE*2);
    Last edited by CaptainBlack; November 8th 2008 at 08:28 AM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by scclebos View Post
    Hello I'm doing a simplified model of a bouncing ball and I am having trouble getting my function DISTANCE to output values for a range of 0:N. I can make it output a single correct value, but not values of 0:N-1...0:0 etc. I have been stuck on this for HOURS. If someone could offer some input on this that would be spectacular.
    My functions are defined as: H0=Initial Height, R=Rebound coefficient, and N=NUmber of bounces. Function HEIGHT finds the height after N bounces, and DISTANCE finds the total vertcial distance. I use (5, .4, [0:7]) to test.

    function [HNN]=HEIGHT(H0, R, N)
    HNN=H0.*R.^N;

    function [TVD]=DISTANCE(H0, R, N)
    [HNN]=HEIGHT(H0, R, N);
    INITIAL=H0;
    FINAL=HNN(length(HNN));
    MIDDLE=HNN(1,2: (length(HNN)-1));
    TVD=FINAL+INITIAL+sum(MIDDLE*2);
    Try:

    Code:
    function HNN=HEIGHT(H0, R, N)
      HNN=H0.*R.^N;
     
     
    function TVD=DISTANCE(H0, R, N)
      [HNN]=HEIGHT(H0, R, N);
      INITIAL=H0;
      FINAL=HNN(length(HNN));
      MIDDLE=HNN(2: (length(HNN)-1));
      TVD=FINAL+INITIAL+2*sum(MIDDLE);
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Nov 2008
    Posts
    2
    That did it. Thanks alot Captain! Now I can finish the rest of the program.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Modeling a function for a set of data help
    Posted in the Pre-Calculus Forum
    Replies: 1
    Last Post: February 17th 2010, 03:46 AM
  2. Cumulative distribution function difficulty
    Posted in the Advanced Statistics Forum
    Replies: 5
    Last Post: March 25th 2009, 09:31 AM
  3. difficulty with one-to-ones
    Posted in the Pre-Calculus Forum
    Replies: 2
    Last Post: February 3rd 2009, 05:38 PM
  4. word problem modeling function
    Posted in the Pre-Calculus Forum
    Replies: 1
    Last Post: April 24th 2007, 12:43 PM
  5. Having a little difficulty
    Posted in the Advanced Statistics Forum
    Replies: 3
    Last Post: June 12th 2006, 04:47 PM

Search Tags


/mathhelpforum @mathhelpforum