Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

clear all

close all
clc

%parameters
Lx = 0.5;

%initialisation
Nx = 4;
dx = Lx/(Nx-1);
T(Nx) = zeros;
e = 1;
niter = 0;
nmax = 1000;
tol = 0.001;

T(1)=300;
T(4)=50;
while niter<nmax
if niter>0
e = T(i);
end
for i = 2:Nx-1
T(i) = 0.5*(T(i-1)+T(i+1));
end
if abs(e-T(i))<tol
break;
end
niter = niter+1;
end
niter
Q1=200*1*(T(1)-T(2))/dx;
Q2=200*1*(T(2)-T(3))/dx;

You might also like