Good afternoon,
I am attempting to construct a graph showing the trajectory of two variables over time, based on a coupled system of differential equations and some arbitrary initial conditions which I'll invariably end up changing later.
The model comes from a Latent Differential Equation model, a form of Structural Equation Modelling. A picture of the structural model I'm trying to build is attached below. From it, a coupled system of differential equations can be formed. I'm trying to plot a graph so I can show the behaviour over time based on different coefficients. As such, I'm trying to make a diagram which enables me to manipulate these coefficients. The bulk of my code is below:
sol[etax_, zetax_, gammay_, gammaydot_, etay_, zetay_, gammax_, gammaxdot_] := NDSolve[{
x''[t] - etax*x[t] - zetax*x'[t] - gammay*y[t] - gammaydot*y'[t] == 0,
y''[t] - etay*y[t] - zetay*y'[t] - gammax*x[t] - gammaxdot*x'[t] == 0,
x[0] == 0.1,
x'[0] == 0.1,
y[0] == 0.1,
y'[0] == 0.1},
y, {x, 0, 10}]
Manipulate[
Plot[Evaluate[y[x] /. sol[etax, zetax, gammay, gammaydot, etay, zetay, gammax,
gammaxdot]], {x, 0, 10},PlotRange -> {Automatic, {-10, 10}}],
{{etax, 1, "etax"}, -3, 3, Appearance -> "Labeled"},
When attempting this, I get a large list of warning messages. I am a little new to the Mathematica/Differential Equations circuit so have probably made a rookie error somewhere, but would really appreciate if anyone could offer any corrections or recommendations which help me with this model building.
Many thanks,
NDSolve
in yoursol
function, I think you want==
(Equal, returns True if lhs and rhs are identical) rather than=
(Set). (2) The NDSolve does not specify a domain fort
, again, I think you want something, e.g., like{x, 0, 10}, {t, 20}
at the end of theNDSolve
using whatever appropriate values you need fort
. I don't see much else one can do to help without more of your code. $\endgroup$