MATLAB中解微分方程在2020b版本中出现警告

syms x y
dsolve('Dy+y*tan(x)=cos(x)','x')

出现警告
警告: Support of character vectors and strings will be removed in a future release. Use sym objects to define
differential equations instead.

这个怎么解决

你好同学,现在标准的求解方法是用diff和申明函数相结合,新的matlab版本对于字符串转符号变量都不支持了,不过只是警告。

syms y(x) % 先申明y是关于x的函数
y = dsolve(diff(y)+y*tan(x)==cos(x))

结果:

y =
 
C1*cos(x) + x*cos(x)