Re: question ,,thankx!!!
- To: mathgroup at smc.vnet.net
- Subject: [mg70709] Re: [mg70681] question ,,thankx!!!
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Tue, 24 Oct 2006 02:24:11 -0400 (EDT)
- Reply-to: hanlonr at cox.net
You need to define r at all points in the interval including 0, 100, 110, 200, and 400. r[t_]:=0/;0<=t<100; r[t_]:=10/;100<=t<110; r[t_]:=2.5/;110<=t<200; r[t_]:=0/;200<=t<=400; Or more simply Clear[r]; r[t_]:= Piecewise[{ {10, 100<=t<110}, {2.5, 110<=t<200}}]; sol=NDSolve[{b'[t]==30a'[t], c'[t]==10a[t](100-c[t])-0.3c[t], d'[t]==400a[t], a'[t]+b'[t]+c'[t]+d'[t]\[Equal]r[t], a[0]==0,b[0]==0,c[0]==0,d[0]==0}, {a[t],b[t],c[t],d[t]},{t,0,400}]; Plot[Evaluate[ {a[t],b[t],c[t],d[t]}/.sol[[1]]], {t,0,400}, PlotStyle->{Red, Blue, Green,Black}, PlotRange->All,Frame->True, Axes->False, ImageSize->500]; Plot[Evaluate[ {a[t],b[t],c[t],d[t]}/.sol[[1]]], {t,0,400}, PlotStyle->{Red, Blue, Green,Black}, PlotRange->{0,0.7},Frame->True, Axes->False, ImageSize->500]; Plot[Evaluate[ {a[t],b[t],c[t],d[t]}/.sol[[1]]], {t,0,400}, PlotStyle->{Red, Blue, Green,Black}, PlotRange->{0,0.025},Frame->True, Axes->False, ImageSize->500]; Table[{t, a[t],b[t],c[t],d[t]}/.sol[[1]]//Chop, {t,0,400,20}] Bob Hanlon ---- walkon <fsun81 at mail.ru> wrote: > hello to everyone! > here question is: > input: > r[t_] := 0 /; (t > 0) && (t < 100) > r[t_] := 10 /; (t > 100) && (t < 110) > r[t_] := 2.5 /; (t > 110) && (t < 200) > r[t_] := 0 /; (t > 200) && (t < 400) > > sol = NDSolve[{b'[t] == 30a'[t], > c'[t] == 10a[t](100 - c[t]) -0.3c[t], > d'[t] ==400a[t], > a'[t] + b'[t] + c'[t] + d'[t] == r[t], > a[0] == 0, b[0] == 0, c[0] == 0, d[0] == 0}, {a[t], b[t], > c[t], d[t]}, {t, 0, 400}] > > Plot[({a[t], b[t], c[t], d[t]} /. sol[[1]] // Evaluate), {t, 0,400}, > PlotRange -> All, Frame -> True] > > who can tell me what 's wrong with the programming? > and if I input a certain r[t] value like: > input: > sol = NDSolve[{b'[t] == 30a'[t], c'[t] == 10a[t](100 - c[t]) -0.3c[t], > d'[t] ==400a[t], a'[t] + b'[t] + c'[t] + d'[t] == 0, a[0] == 10, b[0] > == 0, c[0] == 0, d[0] == 0}, {a[t], b[t], c[t], d[t]}, {t, 0, 100}] > Plot[({a[t], b[t], c[t], d[t]} /. sol[[1]] // Evaluate), {t, 0,100}, > PlotRange -> All, Frame -> True] > output: > [Graphic] > It works well! > so,,whether the programming can only be seperately resolved or not? > > the most important is that I need to get the numerical value of > a[t],b[t],c[t],d[t] > at each time point(0-400),but how to list them from the result of > NDSolve??even I can show the picture. > > thank you very much!!! > -- Bob Hanlon hanlonr at cox.net