Trouble using dsolve function
7 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Walter Roberson
on 20 Jan 2012
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 Comments
Walter Roberson
on 20 Jan 2012
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}))
More Answers (2)
See Also
Categories
Find more on Function Creation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!