[已解决] 编程语法问题

[复制链接]
2436866 发表于 2022-1-7 16:42:34
这样写为什么有警告呢? dsolve('0.5*D2x==-0.2*Dx-10*x','Dx(0)=0','x(0)=0.5')


警告: Support of character vectors and
strings will be removed in a future
release. Use sym objects to define
differential equations instead.
> 位置:dsolve (第 126 行)

ans =

(exp(-t/5)*(499*cos((499^(1/2)*t)/5) + 499^(1/2)*sin((499^(1/2)*t)/5)))/998

最佳答案


WarnerChang 发表于 2022-1-7 17:52:45
本帖最后由 WarnerChang 于 2022-1-7 17:56 编辑

因为这种写法要过时了呗,但是目前还能用

Character vector inputs will be removed in a future release. Instead, use syms to declare variables and replace inputs such as dsolve('Dy = y') with syms y(t); dsolve(diff(y,t) == y).
新的写法如下:


syms x(t) a
eqn = 0.5*diff(x,t,2) == -0.2*diff(x,t)-10*x;
Dx = diff(x,t);
cond = [Dx(0)==0 x(0)==0.5];
dsolve(eqn,cond)

回复此楼

1 条回复


WarnerChang 发表于 2022-1-7 17:52:45
本帖最后由 WarnerChang 于 2022-1-7 17:56 编辑

因为这种写法要过时了呗,但是目前还能用

Character vector inputs will be removed in a future release. Instead, use syms to declare variables and replace inputs such as dsolve('Dy = y') with syms y(t); dsolve(diff(y,t) == y).
新的写法如下:


syms x(t) a
eqn = 0.5*diff(x,t,2) == -0.2*diff(x,t)-10*x;
Dx = diff(x,t);
cond = [Dx(0)==0 x(0)==0.5];
dsolve(eqn,cond)

回复此楼
您需要登录后才可以回帖 登录 | 注册

本版积分规则

相关帖子
相关文章
热门教程
站长推荐
快速回复 返回顶部 返回列表