I wanted to plot vector fields and nullclines for Modified Rosenzweig-MacArthur Model.
and I have a problem plotting p1 and p2 in the same graph on top of each other(I want the vector fields arrows in the range {x2,2,5,4}).
I also have another problem with plotting points of intersections between red and green curves.
a = 0.3556;
b = 0.33;
d = 0.0444;
e = 0.2067;
(*plotting vector field in S1 *)
p1 = StreamPlot[{x1*(1 - x1) - (a*x1*x2)/(b + x1), (a*x1*x2)/(
b + x1) - d*x2}, {x1, 0, 1}, {x2, 0, 2.5}, Axes -> True,
StreamStyle -> Gray, StreamColorFunction -> None];
(*plotting vector field in S2 *)
p2 = StreamPlot[{x1*(1 - x1) - (a*x1*x2)/(b + x1), (a*x1*x2)/(
b + x1) - (d + e)*x2}, {x1, 0, 1}, {x2, 2.5, 4}, Axes -> True,
StreamStyle -> Gray, StreamColorFunction -> None];
(*Solving equations and then plotting the solution trajectory *)
deq1 = x1'[t] == x1[t]*(1 - x1[t]) - (a*x1[t]*x2[t])/(b + x1[t]);
deq2 = x2'[t] == (a*x1[t]*x2[t])/(b + x1[t]) - d*x2[t];
solution1 =
NDSolve[{deq1, deq2, x1[0] == .0001, x2[0] == .0001}, {x1[t],
x2[t]}, {t, 0, 200}];
p3 = ParametricPlot[
Evaluate[{x1[t], x2[t]} /. solution1], {t, 0, 200},
PlotStyle -> Black, PlotStyle -> Thickness[0.005]];
(*plotting nullclines *)
f[x1_, x2_] = x1*(1 - x1) - (a*x1*x2)/(b + x1);
g1[x1_, x2_] = (a*x1*x2)/(b + x1) - d*x2;
g2[x1_, x2_] = (a*x1*x2)/(b + x1) - (d + e)*x2;
(*plotting nullclines of f1 *)
cp1 = ContourPlot[{f[x1, x2] == 0, g1[x1, x2] == 0}, {x1, 0, 1}, {x2,
0, 3}, ContourStyle -> {Green, Red}];
l1 = Graphics[{Thick, Green, Line[{{0, 0}, {0, 3}}]}];
(*plotting nullclines of f2 *)
cp2 = ContourPlot[{f[x1, x2] == 0, g2[x1, x2] == 0}, {x1, 0, 1}, {x2,
0, 3}, ContourStyle -> {Green, Red}];
l2 = Graphics[{Thick, Red, Line[{{0, 0}, {1, 0}}]}];
(*points of intersections *)
ptRules1 = NSolve[{f[x1, x2] == 0, g1[x1, x2] == 0}, {x1, x2}];
ptRules2 = NSolve[{f[x1, x2] == 0, g2[x1, x2] == 0}, {x1, x2}];
(*plotting sliding segment *)
l3 = Graphics[{Thick, Black, Line[{{0, 2.5}, {1, 2.5}}]}];
(*Showing the whole figure *)
Show[p1, p2, p3, l1, l2, l3, cp1, cp2, FrameLabel -> {"x1", "x2"},
Frame -> True]
I will appreciate any help
warm regards
a
? It's undefined above, and that causes lots of errors. $\endgroup$PlotRange
option produce what you want?:Show[p1, p2, p3, l1, l2, cp1, cp2, FrameLabel -> {"x1", "x2"}, Frame -> True, PlotRange -> All]
$\endgroup$