How to solve heat equation on matlab ?
4 次查看(过去 30 天)
显示 更早的评论
dt=0.1;
dx=1;
D=0.002;%thermal coefficient
s=(D*0.1)/(1)^2; %s=D*dt/dx^2
T(1,1)=0.2;%initial condition
t=0:0.1:1;
x=0:1:10;
for n=1:length(t-1)
for j=2:length(x-1)
T(n+1,j)=s*T(n,j+1)+(1-2*s)*T(n,j)+s*T(n,j-1);
end
end
but the error I,m getting is in the matrix dimension :
Index exceeds matrix dimensions.
Error in untitled (line 13) T(n+1,j)=s*T(n,j+1)+(1-2*s)*T(n,j)+s*T(n,j-1);
2 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Heat and Mass Transfer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!