MATLAB: Trouble using dsolve function

dsolveinline()MATLABodeode's

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.

Best Answer

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() .
Related Question