0
$\begingroup$

I am trying to manipulate my parameters eNA, eNM, eMA, eMN, eAM, eAN in the following plot obtained from using NDSolve on my set of differential equations. But I can't find a way to do it. The traditional syntax yields me a blank plot and using doing some modifications yields various errors which I am unable to comprehend.

Here is my code and Plot for the NDSolve solutions

Please help me out ! Any advice would be highly appreciated

Someone below commented that I should include the code itself for people to copy and paste ! So, here it is :

ClearAll[M, A, Ne, t]
r = 0.2;
eMA = 1.5;
eMN = 2;
eAM = 1.7;
eAN = 0.8;
eNM = 2;
eNA = 2.6;

sol = NDSolve[{M'[t] == 
      r*(M[t]*(1 - M[t]/1500) - eMA*M[t]*A[t]/1500 - 
         eMN*M[t]*Ne[t]/1500),
     A'[t] == 
      r*(A[t]*(1 - A[t]/1500) - eAM*A[t]*M[t]/1500 - 
         eAN*A[t]*Ne[t]/1500),
     Ne'[t] == 
      r*(Ne[t]*(1 - Ne[t]/1500) - eNM*Ne[t]*M[t]/1500 - 
         eNA*Ne[t]*A[t]/1500),
     M[0] == 400, A[0] == 400, Ne[0] == 400}, {M[t], A[t], Ne[t]}, {t,
      0, 150}] // Quiet;
M[t_] = M[t] /. sol[[1]][[1]] // Quiet;
A[t_] = A[t] /. sol[[1]][[2]] // Quiet;
Ne[t_] = Ne[t] /. sol[[1]][[3]] // Quiet;
Plot[{M[t], A[t], Ne[t]}, {t, 0, 40}, PlotRange -> {0, 1600}, 
 PlotLegends -> {"M", "A", "Ne"}]
$\endgroup$
1
  • 2
    $\begingroup$ People here generally like users to post code as Mathematica code instead of just images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this meta Q&A helpful $\endgroup$
    – Michael E2
    Oct 30, 2020 at 3:05

1 Answer 1

1
$\begingroup$

It is bad practice and dangerous to use the same symbol name in the ODE and for the solution function. Anyway, with the code below you can play with your parameters.

ClearAll[M, A, Ne, t]
r = 0.2;
Manipulate[
 sol = NDSolve[{M'[t] == 
     r*(M[t]*(1 - M[t]/1500) - eMA*M[t]*A[t]/1500 - 
        eMN*M[t]*Ne[t]/1500), 
    A'[t] == 
     r*(A[t]*(1 - A[t]/1500) - eAM*A[t]*M[t]/1500 - 
        eAN*A[t]*Ne[t]/1500), 
    Ne'[t] == 
     r*(Ne[t]*(1 - Ne[t]/1500) - eNM*Ne[t]*M[t]/1500 - 
        eNA*Ne[t]*A[t]/1500), M[0] == 400, A[0] == 400, 
    Ne[0] == 400}, {M[t], A[t], Ne[t]}, {t, 0, 150}];
 M1[t_] = M[t] /. sol[[1]][[1]] // Quiet;
 A1[t_] = A[t] /. sol[[1]][[2]] // Quiet;
 Ne1[t_] = Ne[t] /. sol[[1]][[3]] // Quiet;
 Plot[{M1[t], A1[t], Ne1[t]}, {t, 0, 40}, PlotRange -> {0, 1600}, 
  PlotLegends -> {"M", "A", "Ne"}]
 , {{eMA, 1.5}, 1, 2}, {{eMN, 2}, 1, 3}, {{eAM, 1.7}, 1, 
  2}, {{eAN, 0.8}, 0.5, 1}, {{eNM, 2}, 1, 3}, {{eNA, 2.6}, 2, 3}, 
 TrackedSymbols :> {eMA, eMN, eAM, eAN, eNM, eNA}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.