Solve with Matlab. Please type code clearly. The thermal efficiency of a straigh
ID: 3811806 • Letter: S
Question
Solve with Matlab. Please type code clearly.
The thermal efficiency of a straight rectangular finned surface is given by eta_fin = tan h mL_c/mL_c Where m is the fin parameter and L_c is the length of the fin plus twice the thickness. For a fin with a 80% efficiency, a thickness of 1mm and m=0.1 mm-1, determine the length of the fin within 4 significant digits of accuracy. Solve using the secant method and initial guesses of LC_0 = 10 and Lc_1 = 20. Set the maximum number of iterations to 30 Include a break statement or use a while loop so when the solution reaches the specified accuracy it will stopExplanation / Answer
Matlab Code
% Given parameters
m = 0.1;
nfin = 0.8;
f = @(Lc) (tanh(m*Lc)./(m*Lc))-nfin; % The efficiency function
x0 = 10;x1 = 20; % Initial guesses
n = 30; % Maximun number of iterations
tol = 10^-4; % Tolerence
iter=1;% intial iteration value
u=f(x0);% function value at x0
v=f(x1);% function value at x1
err(iter)=abs(x1-x0);% error
while (err(iter)>tol)&&(iter<=n)&&((v-u)~=0) % loop to until converg or reach N iter
iter=iter+1;% increase number of iteration
x=x1-v*(x1-x0)/(v-u);% new approximation of root
x0=x1; % replace the old value in x0 with x1
u=v; % replace the old functional value f(x0) with f(x1)
x1=x;% replace the old value in x1 with new value
v=f(x1);% function value at new x1
err(iter)=abs(x1-x0);% error
end
if ((v-u)==0)% Checking devision by zero occured or not
error(' Division by zero')% if yes display error message
elseif (iter>n)% checking method diverge or not
error(' Method failed to converge')% if yes display message
else
fprintf('Lc = %f ',x); % Printing the result
end
Result
Lc = 8.880147