how to solve coupled both differential equations and normal equations

2 views (last 30 days)
I know how to use ode45 to solve the coupled differential equations. The problem now is there are many other variables. Let's say I want to solve coupled differential equations related to variable A (colume matrix) and t. t as the time.
dA(1)/dt= 6x(A(1)-A(2))- B(1)x(A(1)-A(6))
dA(2)/dt= 5x(A(2)-A(3))- B(2)x(A(2)-A(6))
dA(3)/dt= 4x(A(3)-A(4))- B(3)x(A(3)-A(6))
dA(4)/dt= 3x(A(4)-A(5))- B(4)x(A(4)-A(6))
dA(5)/dt= -B(5)x(A(5)-A(6))+C+ D
dA(6)/dt= B(1)x(A(1)-A(6))+B(2)x(A(2)-A(6))+B(3)x(A(3)-A(6))+B(4)x(A(4)-A(6))+B(5)x(A(5)-A(6))+E+F
And the B,C,D,E,F are variables dependent on A(1), A(2),A(3), A(4),A(5), A(5)and also one another.
For example
B(1)+B(2)+B(3)+B(4)+B(5)+B(6)=C
D=6x(A(2)-A(3))
E=7x(A(1)-A(6))
and so on.
And finally I might need to draw A(t) figure and B(t)figure
I don't know how to solve this by using ode45 or if I should still using ode45. Please help. Thank you.

Accepted Answer

Torsten
Torsten on 5 Oct 2015
Before supplying dA(1)/dt,...,dA(6)/dt for ode45, just evaluate the algebraic variables, e.g. D=6*(A(2)-A(3)).
Or what exactly is your problem ?
Best wishes
Torsten.
  2 Comments
jin wang
jin wang on 5 Oct 2015
Thank you for the reply.
My problem is I don't know how to make such relations work in matlab.
And I cannot just evaluate them before using ode45.By then there is no A. But I don't know if it is beacuase of A. I do have initial values for A. But the value of other variables should change along the time with A. if I just evaluate them before ode45 then they will not be evaluated again, since they are not in the ode45 functions.
I hope I explain my struggle here clearly.
Torsten
Torsten on 5 Oct 2015
You don't have to evaluate them before using ode45, but within the function where you compute the time-derivatives.
Look at example 1 under
In the routine "rigid", before supplying dy(1),dy(2) and dy(3) (which could stand for dA(1)/dt,dA(2)/dt and dA(3)/dt), you can evaluate D as D=6*(y(2)-y(3)).
Best wishes
Torsten.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!