Solving coupled differential equations
Show older comments
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
Answers (1)
Bjorn Gustavsson
on 13 Oct 2011
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)
Categories
Find more on Symbolic Math Toolbox 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!