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!