Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Introducing new populations in mathematica graphs

  1. May 18, 2009 #1
    hi i was wondering if anyone knew how to introduce different populations at diffrent times on the same plot on mathematica?
    Say i wanted population 1 have n = 10 at t=0, population 2 to have n=4 at t=0 and then introduce a new population at t=25 so that population 3 would have n= 0 initally but then n= 1 at t = 25.
    Any ideas? the only way I've been gettting around it is to give population 3 really small values initially (e.g. 0.000000000001) but its not very precise.
     
  2. jcsd
  3. May 21, 2009 #2

    Dale

    Staff: Mentor

    What kind of plot are you using? If you are using list plot then you can specify both x and y coordinates in your list. e.g.

    a = Transpose[{Range[10], 2 Range[10]}];
    b = Table[{x, 13}, {x, 3, 10}];
    ListPlot[{a, b}]
     
  4. May 29, 2009 #3
    I'm using Plot [ndsolve] of a set of differential equations. Listplot won't seem to make a list of solutions. I want one populations to have initial conditions of 0 but then at a further time stage to have a vlaue of 1 and see how that changes.
     
  5. May 30, 2009 #4

    Dale

    Staff: Mentor

    If popa and popb are the InterpolatingFunction objects that return from NDSolve then you can do the following:


    truncate[f_InterpolatingFunction, t_] := If[f[[1, 1, 1]] <= t <= f[[1, 1, 2]], f[t]];
    Plot[{truncate[popa, t], truncate[popb, t]}, {t, -1, 6}]
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Introducing new populations in mathematica graphs
Loading...