Plot not working correctly
- To: mathgroup at smc.vnet.net
- Subject: [mg108302] Plot not working correctly
- From: Magbenji <ben.ridenhour at gmail.com>
- Date: Sat, 13 Mar 2010 07:55:46 -0500 (EST)
Hello, I'm having a problem with plotting and I'm not sure what the
cause of it is. What is going on???
Here is what I'm doing:
(*A simple system of ODEs*)
dS[t_]:= -b/P*S[t]*Inf[t]
dInf[t_]:=b/P*S[t]*Inf[t]-g*Inf[t]
dR[t_]:=g*Inf[t]
(*A function to solve the system and return the value of R[100000]*)
ar[r_,s_,pop_]:=Module[{parms,solution},
parms={P->pop,b->r,g->s};
solution=
NDSolve[{S'[t]==dS[t],Inf'[t]==dInf[t],R'[t]==dR[t],S[0]==P-1,Inf[0]==1,R[0]==0}/.parms,
{S,Inf,R},{t,0,100000}];
(R[x]/pop /.solution /. x->100000)[[1]]
]
(*Use ListPlot to look at values; works correctly*)
ListPlot[Table[{i,ar[0.1,i,10000]},{i,0,0.1,0.001}],PlotLabel-
>"CORRECT"]
(*Now try it using Plot; WRONG PLOT*)
Plot[ar[0.1,x,10000],{x,0,0.1}, PlotLabel->"INCORRECT"]