MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Plot not working correctly

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108372] Re: Plot not working correctly
  • From: dh <dh at metrohm.com>
  • Date: Mon, 15 Mar 2010 05:01:36 -0500 (EST)
  • References: <hng21a$rpv$1@smc.vnet.net>

Hi,
this has nothing to do with Plot. It is a matter of localization.
In the ar modul you are using R[x] without localizing x. Therefore, the 
global x is used that already has a value different from what you want.
Daniel


On 13.03.2010 13:56, Magbenji wrote:
> 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"]
>


-- 

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh at metrohm.com>
Internet:<http://www.metrohm.com>



  • Prev by Date: Re: Butterworth filter
  • Next by Date: Generating Valid examples for a list of Functions
  • Previous by thread: Re: Plot not working correctly
  • Next by thread: Putting controls next to graphics in the Manipulate Display area