% Matlab Program To Solve The Discretization Equations Heat Transfer in 1 D Fin % % The M File %
% Matlab Program To Solve The Discretization Equations Heat Transfer in 1 D Fin % % The M File %
Enroll no-09112048,CFD
B.Tech in Chemical Engg.,3
rd
yr. %
% Matlab Program to solve the discretization equations heat transfer in 1 D fin %
% The M file %
ML = input('Enter the value for ML:');
dX = input('Enter the value for dX:');
n=(1/dX);
D=(2+ML*ML*dX*dX);
P=zeros(n,n); %Defining the coefficient matrix P of required
dimensions %
Q=zeros(n,1); %Defining the matrix Q of required dimensions %
i=n;
P(i,i-1)=-2; %fixed based on the mirror image assumption boundary
condition %
P(i,i)=D; %as the equation is
i-1
-D
i
+
i+1
=0, for i=2,3,4,.n-1%
i=i-1;
while(i>1)
P(i,i-1)=-1;
P(i,i)=D;
P(i,i+1)=-1;
i=i-1;
end
P(i,i)=-1;
Q(1,1)=-1;
display(P);
display(Q);
x=P\Q % the required non dimensional temperature %
plot(x);
title('non-dimensional temperature variation of 1-D fin along
the length');
xlabel('discretized point,n');
ylabel('Non dimentional temperature');
The output:
Enter the value for ML:2
Enter the value for dX:0.25
P =
-1.0000 0 0 0
-1.0000 2.2500 -1.0000 0
0 -1.0000 2.2500 -1.0000
0 0 -2.0000 2.2500
Q =
-1
0
0
0
x =
1.0000
0.6599
0.4848
0.4310