analytical solution of ODEs

1 回表示 (過去 30 日間)
Ronald Aono
Ronald Aono 2019 年 11 月 26 日
コメント済み: Ronald Aono 2019 年 11 月 26 日
%calculating the analytical solution for d^2T/dr^2 + 1/r dT/dr = 0
syms r
r = linspace(0.005,0.1,10);
dT = dsolve('1*D2r+((1/r(i))*Dr) =1','r(0.005)=200','r(0.1)=80')
plot(r,dT)
keep getting this error
Error using plot
Data must be numeric, datetime, duration or an array convertible to double.
Error in FD_6a (line 31)
plot(r,dT)

回答 (1 件)

Bjorn Gustavsson
Bjorn Gustavsson 2019 年 11 月 26 日
This should be done thisly:
syms r
syms T(r)
dTdr = diff(T)
d2Tdr2 = diff(T,2)
T = dsolve(1*d2T+((1/r)*dT) ==1,T(0.005)==200,T(0.1)==80)
Tfun = matlabFunction(T)
r_doble = linspace(0.005,0.1,321);
plot(r_double,Tfun(r_double))
HTH
  1 件のコメント
Ronald Aono
Ronald Aono 2019 年 11 月 26 日
still getting the folowing error
Undefined function or variable 'd2T'.
Error in FD_6a (line 30)
T = dsolve(1*d2T+((1/r)*dT) ==1,T(0.005)==200,T(0.1)==80 )

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by