Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: Plot3D

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74014] Re: Plot3D
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Mon, 5 Mar 2007 04:59:23 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <es910n$2po$1@smc.vnet.net> <esb39l$339$1@smc.vnet.net>

Jean-Marc Gulliet wrote:
> yjkingma at telus.net wrote:
>> For the system below I would like to generate a 3D plot of i[t]  when the p=
>> arameter b takes
>> values from say .2 to 3. Please help.
>> jack
>> a==.0002; b==1; c==1; d==.002;
>>
>> so==NDSolve[{s'[t]====-a*s[t]*i[t]-s[t]*i[t]*d*UnitStep[t-b]*(1-Exp[-.1(t-b=
>> )]),
>>
>> i'[t]Sa*s[t]*i[t]-c*i[t],r'[t]Sc*i[t],
>>
>> s[0]S10000,i[0]S1,r[0]====0},{s[t],i[t],r[t]},
>>
>> {t,0,10},MaxSteps=AE1000,StartingStepSize=AE.001];
>>
>> f==Plot[Evaluate[{s[t],i[t],(10000-.5 r[t])}/.so],{t,0,10},PlotPoints=AE500=
>> ,GridLines=AEAutomatic,PlotStyle=AE{{Thickness[.008],RGBColor[1,0,0]},{Thic=
>> kness[.008],RGBColor[0,1,0]},{Thickness[.008],RGBColor[0,0,1]}},Frame=AETru=
>> e]
>>
> 
> Could you, please, post some syntacticly correct code?
> 
> Regards,
> Jean-Marc
> 
On 3/3/07, yj kingma <yjkingma at hotmail.com> wrote:
 >  Hi Jean Marc,
 > hope this is clearer.
 > this is a modified SIR model of an epidemic.
 > with given parameters it gives the numbers of susceptibles, infected
 > individuals and
 > the remaining individuals. works fine.
 > now i want to run a 3D plot of i[t] as one of the parameters is 
varied over
 > a desired range.
 > have not been able to accomplish this. can you?
 > regards,jack.
 >
 >
 >
 >      a=.0002; b=1; c=1; d=.002;
 > 
so=NDSolve[{s'[t]==-a*s[t]*i[t]-s[t]*i[t]*d*UnitStep[t-b]*(1-Exp[-.1(t-b)]),i'[t]Å a*s[t]*i[t]-c*i[t],r'[t]Å c*i[t],
 >  s[0]Å 10000,i[0]Å 1,r[0]==0},{s[t],i[t],r[t]},
 >  {t,0,10},MaxSteps(r)1000,StartingStepSize(r).001];
 >  f=Plot[Evaluate[{s[t],i[t],(10000-.5
 > 
r[t])}/.so],{t,0,10},PlotPoints(r)500,GridLines(r)Automatic,PlotStyle(r){{Thickness[.008],RGBColor[1,0,0]},{Thickness[.008],RGBColor[0,1,0]},{Thickness[.008],RGBColor[0,0,1]}},Frame(r)True]
 >
[I have posted the re-corrected to MathGroup.]

Here is the above code in plain ASCII and InputForm.

In[1]:=
a = 0.0002; b = 1; c = 1; d = 0.002;
so = NDSolve[{Derivative[1][s][t] ==
      (-a)*s[t]*i[t] - s[t]*i[t]*d*UnitStep[t - b]*
        (1 - Exp[-0.1*(t - b)]),
     Derivative[1][i][t] == a*s[t]*i[t] - c*i[t],
     Derivative[1][r][t] == c*i[t], s[0] == 10000,
     i[0] == 1, r[0] == 0}, {s[t], i[t], r[t]},
    {t, 0, 10}, MaxSteps -> 1000, StartingStepSize ->
     0.001];
f = Plot[Evaluate[{s[t], i[t], 10000 - 0.5*r[t]} /.
      so], {t, 0, 10}, PlotPoints -> 500,
    GridLines -> Automatic, PlotStyle ->
     {{Thickness[0.008], RGBColor[1, 0, 0]},
      {Thickness[0.008], RGBColor[0, 1, 0]},
      {Thickness[0.008], RGBColor[0, 0, 1]}},
    Frame -> True];

Regards,
Jean-Marc

P.S. One should use the *InputForm*  when copying an expression from a
Mathematica notebook to an email client. To do so, select the cell(s)
one wants to
include in one's email, then within the *Cell* menu select either
*Convert To* or *Display As* and choose *InputForm*. Finally, copy and
paste as usual.


  • Prev by Date: Re: need MathLie mathematica package
  • Next by Date: Cross sections calculations
  • Previous by thread: Re: Plot3D
  • Next by thread: Means