Académique Documents
Professionnel Documents
Culture Documents
Matlab Code Fin
Matlab Code Fin
% Calculations
Texp=Texper(1:11)
A=((pi/4)*di^2);
P=pi*di;
m=sqrt(h*P/(k*A));
hmk=(h/(m*k));
lx=L-X
mlx=m.*lx
caseb=Tinf+((cosh((mlx))+(hmk.*sinh(mlx)))*(Tb-
Tinf))/(cosh(m*L)+hmk.*sinh(m*L))
casea=Tinf+(exp(-m.*X)*(Tb-Tinf))
a=(1/(dx^2));
b=(-2/(dx^2))-((h*P)/(k*A));
c=-((h*P)*Tinf)/(k*A);
d=-k*A/dx;
e=(k*A)/dx+h*(A+(dx/2)*P);
f=(Tinf*h)*(A+(dx/2)*P);
% Formation of matitrix
coeff=zeros(11);
for i=1:11;
coeff(i,i)=b;
end
for j=1:10;
coeff(j,j+1)=a;
end
for x=2:10;
coeff(x,x-1)=a;
end
coeff(11,10)=d;
coeff(11,11)=e;
% Formation of B matrix
B=zeros(11,1);
B(1,1)=(c-a*Tb);
for y=2:10
B(y,1)=c;
end
B(11,1)=f;
% Solution of matrix A
T=inv(coeff)*B
plot(X,T,'+g:',X,caseb,'*k--',X,Texp,'+m-')
legend('Numerical','Case B','Experimetnal')
xlabel('Distance x(m)')
ylabel('Temperaure (K)')
figure()
plot(X,casea,'+g:',X,caseb,'*k--',X,Texp,'+m-')
legend('Case A','Case B','Experimetnal')
xlabel('Distance x(m)')
ylabel('Temperaure (K)')