Numerically solving a system of equations, both differential and not

2 views (last 30 days)
I have a system of differential equations, all of the type:
dV1/dt=(Pa-Pb)/Ra-(Pb-Pc)/Rb
The R's are constants, but the P's are also variables, and linked through non-differential equations.
I was able to extract most of them and plug in equations using only constants and V's, but some have complex enough equations that it seems no analytical solution is possible.
I've tried to use ODE45, since I was told it could handle a system of equations that included non-differential equations, but it stops on the first variable that hasn't been defined. A simplified version would be:
I started from:
dVdt(1,1)=((Prv-P1)/Ra)-((P2-P3)/Rb); dVdt(2,1)=((P3-Plv)/Rb)-((Plv-P4)/Rc); ...etc
I now have expressions for P1,P2. and Ra,Rb... are constants. But Prv and Plv are connected through several equations (some containing a V variable) and other variables.
For example: (this is very simplified)
Rrv=Pr+Vspt Pl=A*V(1)+B*exp(C*Vspt) ...etc
All together, I have as many equations as variables, but when I tried to get analytical solutions for those non-differential equations so I could plug them in instead of Plv and Prv, it didn't work.
When I try to run ODE45 with all of these equations together, it gives me an error message on the first variable, in this case Vspt.
Is there a way to get ODE45 to treat the non-differential equations as part of the system, and give me a numeric solution for the whole? Or is there another function that would be able to do it?
dsolve doesn't seem to be able to handle this, probably because the lack of an analytical solution.
Thank you!

Accepted Answer

Jan
Jan on 16 Mar 2013
It sounds like you want to solve a DAE, a differential algebraic system, or in other words, an ODE with algebraic constraints. To get more information, type:
docsearch dae

More Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 16 Mar 2013
Edited: Azzi Abdelmalek on 16 Mar 2013
to solve system of nonlinear equations use fsolve
  3 Comments
Azzi Abdelmalek
Azzi Abdelmalek on 16 Mar 2013
To solve dif equation use ode function (ode45,...)
To solve system of nonlinear equations use fsolve
T.C
T.C on 16 Mar 2013
That's my problem - I have both non-differential (and non-linear) equations and differential equations, all in the same system, with at least two variables shared between the two groups.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!