solving non-linear ODEs algebraically with symbolic math toolbox
1 次查看(过去 30 天)
显示 更早的评论
Hi! I'm trying to solve a second order nonlinear ODE for $u_n(t)$, and I have this code:
clear all
n = sym('n');
p = sym('p'); %constant
syms y(x)
d2y = diff(y,2);
dy = diff(y);
dsolve(d2y - (dy)^2/(2*y) - (3*y^3)/2 - 4*x*y^2 - 2*(x^2 + n/2 + (2*p + 1)*(1 + 3*(-1)^n)/4)*y +(n + (2*p + 1)*(1 - (-1)^n))/(4*y) == 0)
I'm getting errors:
Error using assignin Invalid variable name "y(x)" in ASSIGNIN.
Error in syms (line 47) assignin('caller',varargin{1},sym(varargin{1}));
Error in diff_eqn_recc (line 6) syms y(x)
I don't know what's causing this, can anyone help?
Thanks!
1 个评论
RahulTandon
2015-7-8
I tried to solve your problem.Explicit Solution not found. But your errors have been removed! The problem has been rephrased!
回答(1 个)
RahulTandon
2015-7-8
%% Rephrased your problem clc; syms n p x y(x); y = dsolve('D2y - (Dy)^2/(2*y) - (3*y^3)/2 - 4*x*y^2 - 2*(x^2 + n/2 + (2*p + 1)*(1 + 3*(-1)^n)/4)*y +(n + (2*p + 1)*(1 - (-1)^n))/(4*y) == 0','x')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!