Thread: Dope how do you do this

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    39

    Dope how do you do this

    Let x_ini be the initial value and x_fin be the final value in a sequence. If I want to create an array of n points The I just go

    Code:
      x[i] = xini + (xfin - xini)*i/n
    this creates an array of n points starting at xini and excluding the endpoint. No I want the endpoint to be included in the sequence. How do I do this? Should be trival but I can't figure it out.

  2. #2
    Registered User TheBigH's Avatar
    Join Date
    May 2010
    Location
    Melbourne, Australia
    Posts
    426
    Create an array of (n+1) points and instead of looping from i=0 to i=n-1, go from i=0 to i=n.
    Code:
    while(!asleep) {
       sheep++;
    }

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    39
    thanks buddy. Don't want n+1 size array. Just had to divide by n-1 to include the endpoint instead of n

Popular pages Recent additions subscribe to a feed