0
$\begingroup$

I am trying to plot the solutions of the following system as a function of a parameter \[Gamma]. The working code is

\[Omega] = -2;
Manipulate[
sol = First[
 NDSolve[{x'[t] == \[Omega]*x[t] - \[Gamma]*x[t]^2 - \[Alpha]*y[t], 
 x[t /; t <= 0] == 1, 
 y'[t] == \[Omega]*y[t] - \[Gamma]*y[t]^2 - \[Alpha]*x[t], 
 y[t /; t <= 0] == 0}, {x, y}, {t, 0, 10}]];

Plot[Evaluate[Re@{x[t], y[t]} /. sol], {t, 0, 200}, PlotRange -> {{0, 100}, {-100, 100}},
PlotStyle -> {Thick}, Frame -> True], {{\[Gamma], 0.1}, 1, 
10}, {{\[Alpha], 0.1}, 1, 10}]

I have tried with Table but the output gives errors. I want to plot $x$, $y$ as functions of [Gamma], i.e., [Gamma] on the x-axis.

$\endgroup$
2
  • 3
    $\begingroup$ you say you want gamma on x axis, but your plot command uses t for the x axis. but general advice: before throwing everything into Manipulate, first make sure it works outside Manipulate. i.e. see if the plot works, etc.., only then, move things to Manipulate. $\endgroup$
    – Nasser
    Jul 13 '18 at 3:40
  • $\begingroup$ @Nasser, Noted. I will follow your advice. $\endgroup$
    – AtoZ
    Jul 13 '18 at 6:20
1
$\begingroup$
\[Omega] = -2;
Manipulate[
 X = ParametricNDSolveValue[{x'[
      t] == \[Omega]*x[t] - \[Gamma]*x[t]^2 - \[Alpha]*y[t], 
    x[0] == 1, 
    y'[t] == \[Omega]*y[t] - \[Gamma]*y[t]^2 - \[Alpha]*x[t], 
    y[0] == 0}, x, {t, 0, 10}, {\[Gamma]}];
 Y = ParametricNDSolveValue[{x'[
      t] == \[Omega]*x[t] - \[Gamma]*x[t]^2 - \[Alpha]*y[t], 
    x[0] == 1, 
    y'[t] == \[Omega]*y[t] - \[Gamma]*y[t]^2 - \[Alpha]*x[t], 
    y[0] == 0}, y, {t, 0, 10}, {\[Gamma]}];
 Plot[{Re[X[\[Gamma]][t0]], Re[Y[\[Gamma]][t0]]}, {\[Gamma], 1, 10}, 
  PlotRange -> All, PlotStyle -> {Thick}, Frame -> True, 
  FrameLabel -> {"\[Gamma]", ""}], {{t0, 5}, 1, 
  10}, {{\[Alpha], 0.5}, .1, 1}]

fig1

$\endgroup$
2
  • $\begingroup$ Thanks. The first manipulator $t0$ is time? $\endgroup$
    – AtoZ
    Jul 13 '18 at 6:18
  • 1
    $\begingroup$ Yes, t0 is time. $\endgroup$ Jul 13 '18 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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