Re: question ,,thankx!!!
- To: mathgroup at smc.vnet.net
- Subject: [mg70707] Re: question ,,thankx!!!
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Mon, 23 Oct 2006 05:45:09 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <ehhpuq$74a$1@smc.vnet.net>
walkon 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) As written, r[t] is not defined at t == 0, therefore > 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}] returns the following error message: NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`. > Plot[({a[t], b[t], c[t], d[t]} /. sol[[1]] // Evaluate), {t, 0,400}, > PlotRange -> All, Frame -> True] Also, since r[t] is not defined for t == 400, you should restrict the interval to {t, 0, 339}, say. In[1]:= 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) In[5]:= sol=NDSolve[{b'[t]\[Equal]30a'[t],c'[t]\[Equal]10a[ t](100-c[t])-0.3c[t],d'[t]\[Equal]400a[t], a'[t]+b'[t]+c'[t]+d'[t]\[Equal]r[t],a[0]\[Equal]0, b[0]\[Equal]0,c[ 0]\[Equal]0,d[0]\[Equal]0},{a[t],b[t],c[t],d[t]},{t,0,399}] Out[5]= {{a[t]\[Rule] InterpolatingFunction[{{0.,399.}},<>][t],b[t]\[Rule]\ InterpolatingFunction[{{0.,399.}},<>][t],c[ t]\[Rule]InterpolatingFunction[{{0.,399.}},<>][t],d[t]\[Rule]\ InterpolatingFunction[{{0.,399.}},<>][t]}} {t, 0, 399}] In[8]= Plot[Evaluate[{a[t], b[t], c[t], d[t]} /. sol[[1]]], {t, 0, 399}, PlotRange -> All, Frame -> True] [...snipped...] Regards, Jean-Marc