圆柱内径0.05 外径0.25 内边温度500 外边温度10 导热系数0.5
以下是代码
tic
clear
clc
h=0.02;
x=[0.05:h:0.25]';
N=length(x)-1;
f(N-1)=0
f(1)=-500;
f(end)=-10;
e=ones(N-1,1);
C1=(1/h^2)spdiags([e -2e e],[-1 0 1],N-1,N-1);
cc=2hx(2:N);
b=(0.5).*(cc.^-1);
C2=full(spdiags([-b b],[-1 1],N-1,N));
C2(:,N)=[];
C=C1+C2;
f=f';
D=C\f(:);