How can I solve the coupled differential equation with variable coefficients?
Show older comments
I try to solve coupled differential equation in matlab. This is the code I was typed in matlab
syms u(t) v(t)
ode1 = diff(u) == v;
ode2 = diff(v) == ((5/sqrt(2))*exp((1-sqrt(2))*t)-(5/sqrt(2))*exp((1+sqrt(2))*t)+1)*u + (((5*(1-sqrt(2)))/sqrt(2))*exp((1-sqrt(2))*t)-((5*(1+sqrt(2)))/sqrt(2))*exp((1+sqrt(2))*t)+2)*v;
odes = [ode1; ode2]
cond1 = u(0) == 1;
cond2 = v(0) == 0;
conds = [cond1; cond2];
[uSol(t), vSol(t)] = dsolve(odes,conds)
In command window
Warning: Unable to find explicit solution.
> In dsolve (line 190)
In coupled (line 8)
Error using sym/subsindex (line 855)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function body must be sym expression.
Error in coupled (line 8)
[uSol(t), vSol(t)] = dsolve(odes,conds)
Can someone help me with this error? Thank you.
5 Comments
David Goodmanson
on 9 Jan 2020
Edited: David Goodmanson
on 9 Jan 2020
Hi VMRS,
CORRECTED:
If you change the last line to
[uSol vSol] = dsolve(odes,conds)
then you get no errors, just
Warning: Unable to find explicit solution.
> In dsolve (line 190)
which is not really surprising.
Vellapandi M Research Scholar
on 9 Jan 2020
David Goodmanson
on 9 Jan 2020
sorry, I copied in the wrong line. See correction above.
Vellapandi M Research Scholar
on 9 Jan 2020
David Goodmanson
on 9 Jan 2020
that's right. Matlab can't solve it symbolically, but there is always numerically..
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!