# 1D transient heat equation

18 views (last 30 days)
Lindsay Mau on 31 Jul 2020 at 1:28
I am trying to solve this matrix: T=[A]^-1[B]. Initially the temperature is at 80C, but changes as time increases. The change in time is 30 seconds and the number of iterations I want to code for is 120. The current code I have does not work. Somehow I need some guidance how how to update the matrix inside the for loop and display for T(1)-T(10).
n=120; %number of iterations
t=0; %initial time
dt=30; %change in time [seconds]
tmax = 3600; %cool for 1 hr
T_initial = [80; 80; 80; 80; 80; 80; 80; 80; 80; 80; 80]; %initial temperature
A=[-230,50,0,0,0,0,0,0,0,0,0;
50,-460,50,0,0,0,0,0,0,0,0;
0,50,-460,50,0,0,0,0,0,0,0;
0,0,50,-460,50,0,0,0,0,0,0;
0,0,0,50,-460,50,0,0,0,0,0;
0,0,0,0,50,-460,50,0,0,0,0;
0,0,0,0,0,50,-460,50,0,0,0;
0,0,0,0,0,0,50,-460,50,0,0;
0,0,0,0,0,0,0,50,-460,50,0;
0,0,0,0,0,0,0,0,50,-460,50;
0,0,0,0,0,0,0,0,0,50,-330];
B =[-14400;-28800;-28800;-28800;-28800;-28800;-28800;-28800;-28800;-28800;-16400];
for i=1 %initialize solution
T(i)=T_initial;
end
T(1)=T_initial;
while (t < tmax)
i=i+1;
t=t+dt;
for i=2:n-1
T(i) = A\B;
end
end

WILMER ALEXANDER TICONA JUAREZ on 31 Jul 2020 at 6:20
clc
clear
A=[-230,50,0,0,0,0,0,0,0,0,0;
50,-460,50,0,0,0,0,0,0,0,0;
0,50,-460,50,0,0,0,0,0,0,0;
0,0,50,-460,50,0,0,0,0,0,0;
0,0,0,50,-460,50,0,0,0,0,0;
0,0,0,0,50,-460,50,0,0,0,0;
0,0,0,0,0,50,-460,50,0,0,0;
0,0,0,0,0,0,50,-460,50,0,0;
0,0,0,0,0,0,0,50,-460,50,0;
0,0,0,0,0,0,0,0,50,-460,50;
0,0,0,0,0,0,0,0,0,50,-330];
B =[-14400;-28800;-28800;-28800;-28800;-28800;-28800;-28800;-28800;-28800;-16400];
T=A\B

#### 1 Comment

WILMER ALEXANDER TICONA JUAREZ on 2 Aug 2020 at 18:26