Solving coupled differential equations

14 次查看(过去 30 天)
Stijn
Stijn 2011-10-13
Hey,
I've got to solve six coupled differential equations in the form of:
dX(n)/dt = C1 * (X(n-1) - X(n)) - C2*(X(n)-Y(n)/C3)
dY(n)/dt = C4 * (Y(n+1) - Y(n)) - C2*(X(n)-Y(n)/C3)
where n goes from 1 to 3 and X(0) and Y(4) are constants. C1, C2, C3 and C4 are constants as well. I could also write 6 different differetial equations but I figure it is easier with some kind of a loop form.
Could some please get me started on this problem?
Thanks in advance,
Stijn

回答(1 个)

Bjorn Gustavsson
Bjorn Gustavsson 2011-10-13
That would just be 6 lines of code in the function defining your DE:
function dxy = deFcn(t,xy)
dxy(1) = C1 * (xy0 - xy(1)) - C2*(xy(1)-xy(4)/C3)
:
:
dxy(6) = C4 * (xy7 - xy(6)) - C2*(xy(3)-xy(6)/C3)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by