ode45 on a system of differential equations with vectors as variables
Show older comments
Hi all,
I have a system of differential equations:
dX/dT = -X + (1 - X) .* (W(R ) * F(X))
where ".*" means element-wise mulitplication.
dR/dT = c.G(F(X))
where X and R are vectors of equal length, W returns a square matrix with dimensions equal to the length of X, F(x) and G(x) are sigmoid functions each returning a vector and c is a constant.
I've been trying to use ode45 to find numerical solutions for this system but have come across the problem that the initial conditions input, which needs to be a n x 2 matrix of column vectors X0 and R0, seems to get concatenated into a vector of length 2n.
Is it possible to use ode45 on differential equations with vector variables? Should I just split the input vector inside the function definition for the ode system?
At the moment I have:
function xprime = diffs(t,x)
rho = 0.0001;
xprime(1) = -x(:,1) + (1 - x(:,1)) .* (W(x(:,2)) * F(x(:,1)));
xprime(2) = rho * G(F(x(:,1)));
end
and I call it with:
[t,x] = ode45(@diffs,[0 10],[X R])
any help is much appreciated. Thanks in advance for your time.
Alex
1 Comment
Alexander
on 6 Feb 2014
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!