How to solve heat equation on matlab ?

3 views (last 30 days)
alaa akkoush
alaa akkoush on 14 Feb 2018
Reopened: Walter Roberson on 20 Dec 2018
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);

Answers (1)

Torsten
Torsten on 14 Feb 2018
Use MATLAB's "pdepe".
Best wishes
Torsten.

Categories

Find more on Mathematics and Optimization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!