# matlab2015使用dsolve错误,用matlab解常微分方程,调用dsolve是老出错 y=dsolve,用matlab解微分方程y=dsolve(’D2y+Dy2...

> syms x y a;>> dsolve('Dy=-2*x*y/(x^2+2*a)','x')ans =C1/(x^2+2*a)我这里运行没错，你检查一下你的命令中括号等符号是否有问题，是否有输成全角的情况。

>> syms x y0>> y=dsolve('Dy=y+1/y','y(0)=y0','x')y = (-1+exp(2*x)*(1+y0^2))^(1/2) -(-1+exp(2*x)*(1+y0^2))^(1/2)>> help dsolve DSOLVE Symbolic solution of ordinary differential equations. DSOLVE('eqn1','eqn2', ...) accepts symbolic equations representing ordinary differential equations and initial conditions. Several equations or initial conditions may be grouped together, separated by commas, in a single input argument. By default, the independent variable is 't'. The independent variable may be changed from 't' to some other symbolic variable by including that variable as the last input argument. The letter 'D' denotes differentiation with respect to the independent variable, i.e. usually d/dt. A ＂D＂ followed by a digit denotes repeated differentiation; e.g., D2 is d^2/dt^2. Any characters immediately following these differentiation operators are taken to be the dependent variables; e.g., D3y denotes the third derivative of y(t). Note that the names of symbolic variables should not contain the letter ＂D＂. Initial conditions are specified by equations like 'y(a)=b' or 'Dy(a) = b' where y is one of the dependent variables and a and b are constants. If the number of initial conditions given is less than the number of dependent variables, the resulting solutions will obtain arbitrary constants, C1, C2, etc. Three different types of output are possible. For one equation and one output, the resulting solution is returned, with multiple solutions to a nonlinear equation in a symbolic vector. For several equations and an equal number of outputs, the results are sorted in lexicographic order and assigned to the outputs. For several equations and a single output, a structure containing the solutions is returned. If no closed-form (explicit) solution is found, an implicit solution is attempted. When an implicit solution is returned, a warning is given. If neither an explicit nor implicit solution can be computed, then a warning is given and the empty sym is returned. In some cases involving nonlinear equations, the output will be an equivalent lower order differential equation or an integral. Examples: dsolve('Dx = -a*x') returns ans = C1*exp(-a*t) x = dsolve('Dx = -a*x','x(0) = 1','s') returns x = exp(-a*s) y = dsolve('(Dy)^2 + y^2 = 1','y(0) = 0') returns y = sin(t) -sin(t) S = dsolve('Df = f + g','Dg = -f + g','f(0) = 1','g(0) = 2') returns a structure S with fields S.f = exp(t)*cos(t)+2*exp(t)*sin(t) S.g = -exp(t)*sin(t)+2*exp(t)*cos(t) dsolve('Dy = y^2*(1-y^2)') returns Warning:Explicit solution could not be found; implicit solution returned. ans = t+1/2*log(y-1)-1/2*log(y+1)+1/y+C1=0 dsolve('Df = f + sin(t)', 'f(pi/2) = 0') dsolve('D2y = -a^2*y', 'y(0) = 1, Dy(pi/a) = 0') S = dsolve('Dx = y', 'Dy = -x', 'x(0)=0', 'y(0)=1') S = dsolve('Du=v, Dv=w, Dw=-u','u(0)=0, v(0)=0, w(0)=1') w = dsolve('D3w = -w','w(0)=1, Dw(0)=0, D2w(0)=0') y = dsolve('D2y = sin(y)'); pretty(y) See also solve, subs.Reference page in Help browser doc dsolve

>>clear>>syms a b c d e;>>y=dsolve('a*D2y+b*Dy+c*y=0','y(0)=d','Dy(0)=e')y =(2*a*e + b*d + d*(b^2 - 4*a*c)^(1/2))/(2*exp((t*(b - (b^2 - 4*a*c)^(1/2)))/(2*a))*(b^2 - 4*a*c)^(1/2)) - (2*a*e + b*d - d*(b^2 - 4*a*c)^(1/2))/(2*exp((t*(b + (b^2 - 4*a*c)^(1/2)))/(2*a))*(b^2 - 4*a*c)^(1/2))>>a=1;b=1;c=1;d=1;e=1；%若常数已知>>t=1;%desolve中没指定自变量x，这里默认为t，带入任意一个x值>>y=eval(y) y =1.1932 + 0.0000i这是解方程的方法，画图也差不多，我在命令窗写的改麻烦，下面是我在editor写的。

syms a b c d e;y=dsolve('a*D2y+b*Dy+c*y=0','y(0)=d','Dy(0)=e','x');x=200:0.1:400；%取值范围，步长a=1;b=1;c=1;d=1;e=1；%带入参数y=eval(y);plot(x,y)你补充问题的方程解得也是一个空的，并报错，或许就是无解的，我也很疑问。

• 0
点赞
• 0
评论
• 0
收藏
• 一键三连
• 扫一扫，分享海报

04-03

12-04 3092
12-18 2837
05-13 7890
09-28 3191
07-25 3180
06-19 1061
09-04 909
06-18 1265