Trouble using dsolve function
34 次查看(过去 30 天)
显示 更早的评论
Hi,
I need help in solving a 2nd order diff equations. Since my equations are very long (almost 30 lines), I have written a similar code below to explain my question.
z= a*x+b*x^2+c+........; S =dsolve('D2y +5*z+ 2*x + 10*z^2','x')
Now since my z equation is very long I need to substitute z in the dsolve function. I tried using inline function by doing this
z = inline ('a*x+b*x^2+c+........')
but I am not sure if the dsolve program is taking the value of z. Its running though, and it says no explicit solution found and returns me an empty symbol. Am I doing the right thing or is there any other way to do it.
0 个评论
采纳的回答
Walter Roberson
2012-1-20
z = a*x+b*x^2+c+........;
eqn = subs(sym('D2y +5*z+ 2*x + 10*z^2'), z, z);
S = dsolve(eqn, x);
Myself, I would probably toss in a simplify() around the subs() .
2 个评论
Walter Roberson
2012-1-20
The syntax I used is valid for the case of exactly one thing to substitute in. When you have multiple things to substitute in, you must form lists.
eq1 = simplify(subs(...., {'N1', 'N2', 'N3'}, {N1, N2, N3}))
更多回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!