Solving a nonhomogeneous ODE system with 'dsolve'
2 views (last 30 days)
Show older comments
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);
0 Comments
Answers (1)
Star Strider
on 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]
B=[a0/mt*cos(w*t); 0; 0; 0; 0; 0]
Y=[xtt; xt; xbb; xb; xcc; xc
odes = diff(Y) == A*Y + B;
[VF,Subs] = odeToVectorField(odes)
Eqns_Fcn = matlabFunction(VF)
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.
.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!