clc
clear all
%% Prob 1
Dia=12.363
alpha_room=6.47E-6
Tfluid=-108
Troom=80
deltat=Tfluid-Troom
deltaD=Dia*alpha_room*deltat
fprintf ('\nChange in diameter prob1=%g in',deltaD)
%% Prob 2
format long
temp=[80 0 -80 -100 -160  -180  -260  -280  -300 -340];
alpha=[6.47 6.0 5.43 5.28 4.72 4.52 3.58 3.33 3.07  2.45]*1E-6;
coeff=polyfit(temp,alpha,2)
syms T
alphapoly=coeff(1)*T^2+coeff(2)*T+coeff(3)
alphapoly=vpa(alphapoly,6)
fprintf('\nPolynomial approx of alpha is %s',char(alphapoly))
%% Prob 3
deltaD3=Dia*int(alphapoly,T,Troom,Tfluid)
deltaD3=double(deltaD3)
fprintf ('\nChange in diameter prob3=%g in',deltaD3)
%% Prob 4
syms Tf
rhs1=Dia*int(alphapoly,T,Troom,Tf)
lhs1=-0.015
eqn1=[char(rhs1) '=' num2str(lhs1)]
soln=solve(eqn1,Tf)
soln=double(soln)
fprintf ('\nFluid temp needed=%g F\n',soln(2))
