Solving a nonhomogeneous ODE system with 'dsolve'

1 Ansicht (letzte 30 Tage)
Namkeun Kim
Namkeun Kim am 2 Jan. 2022
Beantwortet: Star Strider am 2 Jan. 2022
To solve a nonhomogeneous ODE system, I used the next code, but it didn't work and showed the following error messages.
Could you check where is the problem?
=================================
syms ct mt kt cb mb kb mc w a0 xtt(t) xt(t) xbb(t) xb(t) xcc(t) xc(t)
A=[-ct/mt -kt/mt ct/mt kt/mt 0 0;
1 0 0 0 0 0;
ct/mb kt/mb -(ct+cb)/mb -(kt+kb)/mb cb/mb kb/mb;
0 0 1 0 0 0;
0 0 cb/mc kb/mc -cb/mc -kb/mc;
0 0 0 0 1 0];
B=[a0/mt*cos(w*t); 0; 0; 0; 0; 0];
Y=[xtt; xt; xbb; xb; xcc; xc];
odes = diff(Y) == A*Y + B;
[xttSol(t), xtSol(t), xbbSol(t), xbSol(t), xccSol(t), xcSol(t)]=dsolve(odes);
===================================
Error using mupadengine/feval_internal (line 172)
Invalid operand.
Error in dsolve>mupadDsolve (line 328)
T = feval_internal(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 183)
sol = mupadDsolve(args, options);
Error in odesys (line 19)
[xttSol(t), xtSol(t), xbbSol(t), xbSol(t), xccSol(t), xcSol(t)]=dsolve(odes);

Antworten (1)

Star Strider
Star Strider am 2 Jan. 2022
I have no idea what the problem is with this, however I’ve been running it offline on my computer (using a Laplace transform approach) for about 4 hours and I have no results. I am now convinced that in spite of its apparent simplicity, it does not have a symbolic solution.
Try this instead —
syms ct mt kt cb mb kb mc w a0 xtt(t) xt(t) xbb(t) xb(t) xcc(t) xc(t) t
A=[-ct/mt -kt/mt ct/mt kt/mt 0 0;
1 0 0 0 0 0;
ct/mb kt/mb -(ct+cb)/mb -(kt+kb)/mb cb/mb kb/mb;
0 0 1 0 0 0;
0 0 cb/mc kb/mc -cb/mc -kb/mc;
0 0 0 0 1 0]
A = 
B=[a0/mt*cos(w*t); 0; 0; 0; 0; 0]
B = 
Y=[xtt; xt; xbb; xb; xcc; xc
odes = diff(Y) == A*Y + B;
[VF,Subs] = odeToVectorField(odes)
Eqns_Fcn = matlabFunction(VF)
Y(t) = 
VF = 
Subs = 
Eqns_Fcn = function_handle with value:
@(Y,a0,cb,ct,kb,kt,mb,mc,mt,t,w)[Y(2);(a0.*cos(t.*w))./mt-(ct.*Y(2))./mt+(ct.*Y(3))./mt-(kt.*Y(1))./mt+(kt.*Y(4))./mt;-((cb+ct).*Y(3))./mb-((kb+kt).*Y(4))./mb+(cb.*Y(5))./mb+(ct.*Y(2))./mb+(kb.*Y(6))./mb+(kt.*Y(1))./mb;Y(3);(cb.*Y(3))./mc-(cb.*Y(5))./mc+(kb.*Y(4))./mc-(kb.*Y(6))./mc;Y(5)]
Use ‘Eqns_Fcn’ with the numeric differential equation integrator (ode45 or ode15s for example, depending on the coefficient values) to integrate it numerically. That call would likely be ‘@(t,Y)Eqns_Fcn(Y,a0,cb,ct,kb,kt,mb,mc,mt,t,w)’. Use ‘string(Subs)’ in the legend argument to appropriately display and label the results.
This is the best I can do (and likely the best MATLAB can do) for this problem.
.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by