I am trying to solve a set of linear equations of heat transfer conduction using gauss seidel iteration, but my solutions seem not to correct compared to the exact or analytic solution.
3 次查看(过去 30 天)
显示 更早的评论
this are the codes below.
clear all;
N=4; % Number of columns
M=4; % Number of rows
error_T=ones(4,4);
T_amb = 300;% initial emperatures in matrix
T=ones(4,4)*T_amb;% create 4x4 matrix with Tamb
T_old=zeros(4,4);
T(:,1)=100;% boundary condition at the left
T(:,4)=100;% boundary condition at the right
T(1,:)=500;% boundary condition at the top
T(4,:)=100;% boundary condition at the bottom
for m=2:M-1;
for n=2:N-1
% Calculcate temperature at
while error_T(m,n)>= 0.01
T_old=T(m,n);
T(m,n) = 1/4*(T(m+1,n)+T(m-1,n)+T(m,n+1)+T(m,n-1));
error_T(m,n)=abs((T(m,n)-T_old)/T(m,n))*100;
end
end
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!