solve a differential equations system with DSOLVE

Hello.
I need to solve a differential equation's system in matlab composed by 6 equations: 5 of them are differential and se sixth one is linear without derivatives. All the equations contain both the corresponding unknown variable and one or two other unknown variables that are to be calculated in the other equations. Moreover, in each equation I have coefficients that depend from the unknown quantities.
I tried to write in Matlab (i give an example with only 3 derivatives dTi/dt plus a simple linear equation, and without coefficients):
DTg = ((Tg^2+Tamb^2)*(Tg+Tamb))*(Tamb-Tg)+((Tg^2+Tamb^4)*(Tg+Tamb))*(Tpv-Tg);
DTpv = ((Tg^2+Tamb^2)*(Tg+Tamb))*(Tg-Tpv)+(Tf-Tpv)+(Tamb-Tpv);
DTf = ((Tpv-Tf)-(Tf2-Tf0));
Tf2 = 2*Tf-Tf0;
The unknown variables are Tg,Tpv, Tf and Tf2, which are both in the derivatives and in the second member of the equations.
How can I solve that? I tried using:
dsolve('DTg','DTpv','DTf','Tf2','Tg(0)=Tamb','Tpv(0)=300','Tf(0)=Tf0');
but of course it doesn't work because matlab wants to know tha values of Tg, Tpv, Tf and Tf2 in the second members of the equations.
No idea of how to solve this system.
Thank you to everybody answers!

1 Kommentar

Valentina
Valentina am 16 Mär. 2012
I tried that:
syms x y z w
S = dsolve('Dx - y*c/e - x^3*y*b/e + x*b*Tamb^3/e - x^4*a/e + x^3*b/e + a/e*Tamb^4 + b/e*Tamb^3 + d/e=0',...
'Dy - z*f/m + y*a*Tamb^3/m + y*f/m + y/(m*g) - Y*i*l/m + x^3*y*a/m + x*a*Tamb^3/m - x^4*a/m + Tamb/(m*g) + h/m - i/m - i*l/m*T_ref=0',...
'Dz + w *n/o + z*f/o - y*f/o + n*Tf0/o=0',...
'w -z*2 +Tf0=0');
Doesn't work.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Kai Gehrs
Kai Gehrs am 19 Mär. 2012

0 Stimmen

Hi Valentina, hi All,
I have tried to solve the example symbolically and I also did not find a way. When entering
dsolve('DTg=((Tg^2+Tamb^2)*(Tg+Tamb))*(Tamb-Tg)+((Tg^2+Tamb^4)*(Tg+Tamb))*(Tpv-Tg)',...
'DTpv=((Tg^2+Tamb^2)*(Tg+Tamb))*(Tg-Tpv)+(Tf-Tpv)+(Tamb-Tpv)',...
'DTf=((Tpv-Tf)-(Tf2-Tf0))',...
'Tf2=2*Tf-Tf0','Tg(0)=Tamb','Tpv(0)=300','Tf(0)=Tf0');
in MATLAB I get the information that the internal system solver cannot handle this kind of problem.
You probably should be looking for a numerical solution. Since the last equation does not contain derivatives, it may be worth trying a numerical solver which can handle "differential algebraic equations". There are solvers in MATLAB which can handle these kinds of equations. Just search the help for "differential algebraic equations" or DAE (the short form).
Best regards,
-- Kai

Weitere Antworten (1)

Sean de Wolski
Sean de Wolski am 16 Mär. 2012

0 Stimmen

Did you define those variables as syms?
syms Tg Tpv Tf Tf2
first.

6 Kommentare

Valentina
Valentina am 16 Mär. 2012
Looking to Kai Gehrs' answer at http://www.mathworks.it/matlabcentral/answers/30774-system-of-two-linear-ordinary-differential-equations I thought the syms were the coefficients, not the unknown variables I want calculate. So, I have to put as syms these variables, and then?
Thank you.
Sean de Wolski
Sean de Wolski am 16 Mär. 2012
Or as constants, but yes, they have to be defined.
Valentina
Valentina am 17 Mär. 2012
I've done what you said:
syms x y z w real
S = dsolve('Dx -(((a*(x^2+Tamb^2)*(x+Tamb)*(Tamb-x)+ (b*(x^2+Tamb^2)*(x+Tamb)+c)*(y-x)+d))/e) = 0',...
'Dy -(((a*(x^2+Tamb^2)*(x+Tamb))*(x-y)+(f*(z-y))+((Tamb-y)/g)+(h-i*(1-l*(y - T_ref))))/m) = 0',...
'Dz -((f*(y-z)-n*(w-Tf0))/o)=0',...
'w - 2*z+Tf0 = 0',...
'x(0)=Tamb', 'y(0)=299', 'z(0)=288',...
'IgnoreAnalyticConstraints', 'none');
Matlab tells me:
??? Attempt to execute SCRIPT dsolve as a function:
Error in ==> dsolve at 25
S = dsolve('Dx -(((a*(x^2+Tamb^2)*(x+Tamb)*(Tamb-x)+
(b*(x^2+Tamb^2)*(x+Tamb)+c)*(y-x)+d))/e) = 0',...
What is wrong?
Do not name your own script dsolve.m !
arnold ing
arnold ing am 4 Sep. 2017
Bearbeitet: arnold ing am 4 Sep. 2017
Hi Its the same for me..its not about the script name
What shows up for
which -all dsolve

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by