MATLAB: How to solve a system of equations

differential equations

Hello,
suppose I've got four equations which depend on one another and one of them depends on the time:
a = f(b);
b = f(c);
c = f(d);
d = f(a,t);
How can a system like this be solved? I thought about using one of the ode solvers but failed to implement the functions. Can anybody give me a hint?
Thanks in advance,
J

Best Answer

You need to have a function which the ode solvers can act on.
[t,y] = ode45('YourODEFunction', [0 50], [a(0) b(0) c(0) d(0)])
An example of how to create the function:
function dA=YourODEFunction(x,A)
dA(1)=f(b); %Equation for a,
dA(2)=f(c); %Equation for b
dA(3)=f(d); %Equation for c
dA(4)=f(a,t); %Equation for d
dA=dA'
Note that when you have f(b) (and all the others) you'd have to type in an experission eg
dA(1)=3*A(2) %Coding up of a=3*b
Any time your equation would have a 'b' use A(2), any time you would use an 'a' use A(1), any time you would use a 'c' use A(3) and 'd' use A(4). Does that make sense?