How to solve a differential equations system?
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
I have the equations system below:
d(na)/dt=-r*V;
d(nw)/dt=-r*V;
d(nb)/dt=-r*V;
d(H)/dt=-AhU*(6*T-360);
H=na*(DhfA+Cpa*(T-25))+nb*(DhfB+Cpb*(T-25))+nw*(DhfW+Cpw*(T-25));
V=(na/pa)+(nb/pb)+(nw/pw);
r=Ko*exp(EdiaR/T)*na/V;
with na,nw,nb,V,r,t,H the unknown functions and na(0)=10 and nb(0)=20
this is my code below but it doesn't seem to work at all. Any help please?
syms na nw nb V T H r ;
c1=na(0)==10;
c2=nw(0)==20;
eqn1=diff(na)==-r*V;
eqn2=diff(nw)==-r*V;
eqn3=diff(nb)==-r*V;
eqn4=diff(H)==-AhU*(6*T-360);
eqn5=H==na*(DhfA+Cpa*(T-25))+nb*(DhfB+Cpb*(T-25))+nw*(DhfW+Cpw*(T-25));
eqn6=V==(na/pa)+(nb/pb)+(nw/pw);
eqn7=r==Ko*exp(EdiaR/T)*na/V;
S=dsolve(eqn1,eqn2,eqn3,eqn4,eqn5,eqn6,eqn7,c1,c2)
0 个评论
回答(3 个)
Torsten
2015-10-21
0 个投票
The system is too complex to be solved with dsolve.
Use a numerical solver instead (e.g. ODE15S).
You will also need initial values for nb and H.
Best wishes
Torsten.
0 个评论
Walter Roberson
2015-10-21
0 个投票
You did not declare na to be a function, so diff(na) is going to be 0 (or maybe 1).
When you use diff() to express the form, you should use functional form, like diff(na(t),t)
2 个评论
Aristos Manolarakis
2015-10-21
Walter Roberson
2015-10-21
R2011a does not support function notation for syms. Use
syms f g t
c1 = f(0)==0;
c2 = g(0)==0;
eqn1 = diff(f(t),t) == 3*f(t) + 4*g(t);
eqn2 = diff(g(t),t) == -4*f(t) + 3*g(t);
S = dsolve(eqn1, eqn2, c1, c2)
I do not recall at the moment whether R2011a supported symbolic "==". You might need to use
c1 = f(0) - 0;
c2 = g(0) - 0;
Torsten
2015-10-21
Remove the ";" after the syms declaration.
Maybe it will also be necessary to replace
eqn1 = diff(f(t),t) == 3*f + 4*g;
eqn2 = diff(g(t),t) == -4*f + 3*g;
by
eqn1 = diff(f) == 3*f + 4*g;
eqn2 = diff(g) == -4*f + 3*g;
, but I'm not sure.
Best wishes
Torsten.
3 个评论
Aristos Manolarakis
2015-10-21
Torsten
2015-10-21
You still get the error ? Or did it vanish after the changes ?
If the error persists, you should consult the MATLAB 2011a documentation. I'm sure there are examples for the use of "dsolve" with two unknown functions plus initial conditions.
Best wishes
Torsten.
Aristos Manolarakis
2015-10-21
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!