MATLAB微分方程中出現(xiàn)警告: Support of character vectors and strings will b

MATLAB微分方程中出現(xiàn)
警告: Support of character vectors and strings will be removed in a future release. Use sym objects to define differential equations instead.?
原因是現(xiàn)在微分方程(dsolve函數(shù))標準的求解方法是用diff和申明函數(shù)相結(jié)合,新的matlab版本對于字符串轉(zhuǎn)符號變量都不支持了,只是警告,計算結(jié)果是沒有問題的。
標準求解:
syms y(t)
dsolve(diff(y,t) == y)
S = dsolve(eqn)
S = dsolve(eqn,cond)
S = dsolve(eqn,cond,Name,Value)
[y1,...,yN] = dsolve(___)
eqn代表一個符號方程。
cond代表使用初始條件或邊界條件條件。
例子:

出現(xiàn)警報的例子:
?>>y = dsolve('D2y+4*Dy+29*y','y(0)=0,Dy(0)=15','x')
y =
?
3*sin(5*x)*exp(-2*x)
標準的求解方法的例子:
syms y(x)??% 先申明y是關(guān)于x的函數(shù)
>> eqn = diff(y,2)+4*diff(y)+29*y==0;
>> Dy = diff(y);
>> cond = [y(0)==0,Dy(0)==15];
>> ySol(x) = dsolve(eqn,cond)
?
ySol(x) =
?
3*sin(5*x)*exp(-2*x)
總結(jié):對于當前快速計算而言,可以忽視警報。對于完美運行程序者,請使用標準解法。
