Message Boards Message Boards

0
|
5828 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:
GROUPS:

Can anyone explain why my code isn't working?

Posted 10 years ago
POSTED BY: Kelly Hawes
2 Replies

You tried to find analytical solution the turning it to numbers N[DSolve... better above or:

In[10]:= sol = 
 NDSolve[{A'[t] == 0.5/((1 + (B[t]/.5))^10) - 0.2 A[t], 
   B'[t] == 0.5/(1 + (A[t]/2))^10 - 2 B[t], A[0] == 0, 
   B[0] == 0}, {A[t], B[t]}, {t, 0, 120}]

Out[10]= {{A[t] -> InterpolatingFunction[{{0., 120.}}, <>][t], 
  B[t] -> InterpolatingFunction[{{0., 120.}}, <>][t]}}

In[11]:= Plot[{A[t], B[t]} /. sol, {t, 0, 120}]

solution

POSTED BY: Kay Herbert
Posted 10 years ago

Best is to use the function NDSolveValue. For example as follows:

{Asol, Bsol} = 
 NDSolveValue[{A'[t] == 0.5/((1 + (B[t]/.5))^10) - 0.2 A[t], 
   B'[t] == 0.5/(1 + (A[t]/2))^10 - 2 B[t], A[0] == 0, B[0] == 0}, {A,
    B}, {t, 0, 120}]
Plot[{Asol[t], Bsol[t]}, {t, 0, 120}]

and get: enter image description here

POSTED BY: Erik Mahieu
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract