0% found this document useful (0 votes)
47 views5 pages

Matlab Code HTLab 1

Code for Matlab to find the heat transfer coefficient and effectiveness of heat transfer from a fin.

Uploaded by

motorph
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views5 pages

Matlab Code HTLab 1

Code for Matlab to find the heat transfer coefficient and effectiveness of heat transfer from a fin.

Uploaded by

motorph
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Matlab Code

% Loading in data
fid=fopen('dataset1.txt','r');
text2discard=textscan(fid,'%s',11,'delimiter', ' ', 'HeaderLines',0);
data=textscan(fid,'%f %f %f %f','delimiter', ' ', 'HeaderLines',0);
fclose(fid);
locationNo=data{1};
steel_1d0_in1=data{2};
alum_0d5_in1=data{3};
alum_1d0_in1=data{4};
fid=fopen('dataset2.txt','r');
text2discard=textscan(fid,'%s',11,'delimiter', ' ', 'HeaderLines',0);
data=textscan(fid,'%f %f %f %f','delimiter', ' ', 'HeaderLines',0);
fclose(fid);
locationNo=data{1};
steel_1d0_in2=data{2};
alum_0d5_in2=data{3};
alum_1d0_in2=data{4};
% Array of Thermocouple Positions
x=[0,0.1,0.5,1,1.5,2,2.5,3]*0.3048;
% Diameter
D=1*0.0254;
% Perimeter
P=pi*D;
% Area
A=(pi*D^2)/4;
% Length of Fins
L=3*0.3048+7.94E-3;
% k for aluminum
K=177;
% k for steel
K_st=15;
% Average Ambient Temperature
t_amb=(21.227766+21.230077)/2;
t_amb=mean([21.227766,21.230077])+273;
% Average Base Temperature
t_b=mean([124.692058,125.630037])+273;
%Discarding data points 3 and 5 because of faulty thermocouples
alum_1d0_in1
alum_1d0_in1 =
108.7503
98.9269
187.4615
76.2896
175.4703

Matt King

56.3363
43.7889
36.1148
31.3809
27.9631
alum_1d0_in1=[108.7503
98.9269
76.2896
56.3363
43.7889
36.1148
31.3809
27.9631];
steel_1d0_in1
steel_1d0_in1 =
103.0832
81.2167
239.1964
39.4183
29.7386
24.5751
21.6551
21.0722
20.9988
21.2724
steel_1d0_in1=[ 103.0832
81.2167
39.4183
24.5751
21.6551
21.0722
20.9988
21.2724];
alum_1d0_in2
alum_1d0_in2 =
109.4526
99.4810
186.4798
76.3777
172.4078
56.3756
43.9052
36.2717
31.5080
27.9576
alum_1d0_in2=[109.4526

99.4810
76.3777
56.3756
43.9052
36.2717
31.5080
27.9576];
steel_1d0_in2
steel_1d0_in2 =
103.5309
81.3608
239.1981
39.6509
29.9680
24.6882
21.6893
21.1543
21.0091
21.3066
steel_1d0_in2=[103.5309
81.3608
39.6509
24.6882
21.6893
21.1543
21.0091
21.3066];
% Average of temperatures
alum_1d0_in=(alum_1d0_in1+alum_1d0_in2)/2;
steel_1d0_in=(steel_1d0_in1+steel_1d0_in2)/2;
% Calculate theta_exp
Thetai_exp_Al=alum_1d0_in-t_amb;
Thetab_exp_Al=t_b-t_amb;
theta_exp_Al=Thetai_exp_Al./Thetab_exp_Al;
Thetai_exp_St=steel_1d0_in-t_amb;
Thetab_exp_St=t_b-t_amb;
theta_exp_St=Thetai_exp_St./Thetab_exp_St;
% Initial guess for heat transfer coefficient
h=linspace(1,50,10000);
% Determine heat transfer coefficient using least squares method
theta_exp_Al=theta_exp_Al';
for i = 1:length(h)
m = sqrt((h(i).*P)./(K*A));
thetai_theory_Al = cosh(m.*(L - x)) + (h(i)/(m*K)).*...
sinh(m.*(L - x));
thetab_theory_Al = cosh(m*L) + (h(i)/(m*K))*sinh(m*L);

theta_theory_Al = thetai_theory_Al./thetab_theory_Al;
e_i =theta_exp_Al - theta_theory_Al;
S_r_Al(i) = sum(e_i.^2);
end
theta_exp_St=theta_exp_St';
for i = 1:length(h)
m = sqrt((h(i).*P)./(K_st*A));
thetai_theory_St = cosh(m.*(L - x)) + (h(i)/(m*K_st)).*...
sinh(m.*(L - x));
thetab_theory_St = cosh(m*L) + (h(i)/(m*K_st))*sinh(m*L);
theta_theory_St = thetai_theory_St./thetab_theory_St;
e_i =theta_exp_St - theta_theory_St;
S_r(i) = sum(e_i.^2);
end
% Value and location of smallest Sr
[value,location] = min(S_r_Al);
Actual_h = h(location)
[value,location] = min(S_r);
Actual_h = h(location)
Actual_h =
50
Actual_h =
50
% Plotting theta_exp and curve fit line vs x/L
m = sqrt((Actual_h.*P)./(K*A));
thetai_theory = cosh(m.*(L - x)) + (Actual_h/(m*K)).*...
sinh(m.*(L - x));
thetab_theory = cosh(m*L) + (Actual_h/(m*K))*sinh(m*L);
theta_theory_actual = thetai_theory/thetab_theory;
plot(xL,theta_exp_Al,'-b',xL,theta_theory_actual,'-r')
title('Curve Fit of Experimental and Theoretical Data');
xlabel('Position [m]');
ylabel('Thetai/Thetab');
legend('Experimental Data','Theoretical Data');
m = sqrt((Actual_h.*P)./(K_st*A));
thetai_theory = cosh(m.*(L - x)) + (Actual_h/(m*K_st)).*...
sinh(m.*(L - x));
thetab_theory = cosh(m*L) + (Actual_h/(m*K_st))*sinh(m*L);
theta_theory_actual = thetai_theory/thetab_theory;

plot(xL,theta_exp_St,'-b',xL,theta_theory_actual,'-r')
title('Curve Fit of Experimental and Theoretical Data');
xlabel('Position [m]');
ylabel('Thetai/Thetab');
legend('Experimental Data','Theoretical Data');

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy