What is wrong with my code below
f1[ar_, cj_, mj_, tj_, kj_, s_, w_] :=
ar*J[t] + cj*R[t] + mj*J[t] - tj*R[t] - kj*J[t] + s*R[t]*J[t] + w*J[t]*R[t];
g1[aj_, cr_, mr_, tr_, kr_, s_, w_] :=
aj*R[t] + cr*J[t] + mr*R[t] - tr*J[t] - kr*R[t] - s*R[t]*J[t] - w*J[t]*R[t];
splot = StreamPlot[{f[1, 1, 0, 0, 1, 1], g[1, 1, 0, 0, 1, 1]}, {J, -4,4},{R, -4, 4}];
Manipulate[Show[splot,ParametricPlot[Evaluate[First[{x[t], y[t]} /.
NDSolve[{J'[t] == f1[1, 1, 0, 0, 1, 1], R'[t] == g1[1, 1, 0, 0, 1, 1],
Thread[{x[0], y[0]} == point]}, {x, y}, {t, 0, T}]]], {t, 0,T}, PlotStyle -> Red]],
{{T, 10}, 1, 100}, {{point, {1, 0}}, Locator}, SaveDefinitions -> True]
I am getting the error
ConstantArray::ilsmn: Single or list of non-negative machine-sized integers expected at position 2 of ConstantArray[{J,R},-\[Infinity]].
Manipulate
andParametricPlot
. The error occurs already when executingNDSolve[{J'[t] == f1[1, 1, 0, 0, 1, 1], R'[t] == g1[1, 1, 0, 0, 1, 1], Thread[{x[0], y[0]} == point]}, {x, y}, {t, 0, T}]
. You try to solve forx
andy
but the equations are in terms ofJ
andR
. And you definedf1
andg1
as functions in seven variables but you call them only with six variables.NDSolve[{ J'[t] == f1[1, 1, 0, 0, 1, 1, 1], R'[t] == g1[1, 1, 0, 0, 1, 1, 1], Thread[{J[0], R[0]} == point] }, {J, R}, {t, 0, T}]
seems to work. $\endgroup$