Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1-2. Friction factorffor an incompressible flow through a smooth pipe is approxi

ID: 701270 • Letter: 1

Question

1-2. Friction factorffor an incompressible flow through a smooth pipe is approximately 16 if Re s 2100 0.0791 Re Re > 2100 Where Re is a Reynolds number. 1. Write a function file HW3_1_YourLastName.m that accepts Re and returns. 2. Write a script file HW3_2_YourLastName.m that uses HW3_1_YourLastName.m to generate an array of ffor 1000 s Re s 3000 using a for loop and to make a plot of f (Re). Let the array have 10U0 elements. Label both axes in the graph. Because the function is just an pproximation, nbrupt jump occurs at Re= 2100 3. To calculate x = Va , ancient people formulated xalx 2 which is simplified to be x-a. In MATLAB, using eq. (1), we can obtain x by an iterative method with an initial guess. For example, to calculate x = V2 , we use an initial guess of x = 1 and calculate the right hand side of eq. (1) as 1.5. This result is used as a new guess for x. In the next 1.4167. In this case, 1.5 is called the iteration, the right hand side of eq. (1) becomes first iteration solution and 1.4167 is the second iteration solution. Write a script file HW3-3-Your! astName.m t calculate the 10th iteration solution nt x =20 using a tor lnop. F r an initial guess, use x-4. To be accurate, use format long 2

Explanation / Answer

1.

function y = HW3_1_YourLastName(Re)
if(Re > 2100 )
y = 0.0791/Re^(0.25);
else
y = 16/Re;
end
end

*********************************************************************************************************************

2.

function HW3_2_YourLastName()
Re = linspace(1000,3000,1000);
f = zeros(size(Re));
  
for j=1:length(Re)
f(j) = HW3_1_YourLastName(Re(j));
end
  
plot(Re,f,'r-');
xlabel('Re');
ylabel('f','Rotation',0);
grid on;
end

**************************************************************************************************

3.

function y = HW3_3_YourLastName(a, initial_guess, iteration)
x = initial_guess;
  
for i = 1:iteration
y = 0.5*(x + a/x);
x = y;
end
end

HW3_3_YourLastName(20, 4, 10) // use this for root(20) from another script