Introducing new populations in mathematica graphs

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 3K views
pemb09
Messages
2
Reaction score
0
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.
 
Physics news on Phys.org
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}]
 
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.
 
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}]