Matlab. Please help.
Relative roughness /D. Colebrook (1910-1997) developed the following implicit relation known as the Colebrook equation:
Re = 4000
(2.1)
You must note that f is implicit and appears on both sides of Equation (1). Accordingly, to determine the friction coefficient f numerically, an iterative technique must be developed. You need to find the friction factor, f, for a range of the relative roughness and Reynolds number Re. Write a program in a script file HW6P2 that iteratively determines f from equation (1). The program must prompt the user to enter the relative roughness and Reynolds number Re, as well as a guess value of the friction coefficient fguess. To develop the iterative technique for determining the turbulent friction coefficient, Equation (1) can be rewritten as:
(2.2)
The iteration must continue until fcar and fguess are very close to each other by a specific tolerance. After entering fguess, the right-hand side of Equation (2.2) can be calculated and the result will be assigned to fguess. If the absolute difference between fcar and fguess is less than 10^-15, the iteration must stop and the last value of fcar must be displayed. Otherwise, the iteration must continue within a while loop. In order to avoid an infinite loop in case of divergence, you must create a counter for the number of iterations and set a maximum of 20 iterations. If this number is reached before the 10^-15 precision is reached, the program should display the message: "The program failed to converge in the allowable number of iterations, please change the initial guess value of f." If the value of f converges to the specified precision in less than 20 iterations, the output must be displayed as: "For Re = X.XXEXX and a relative roughness e/D = X.XXEXX, the turbulent friction factor converged to f = X.XXXXXEXX in XX iterations." Test your program with the following inputs: 1. Re = 10,000, e/D = 0.0045, and fguess = 1. 2. Re = 100,000, e/D = 0.0025, and fguess = 10. 3. Re = 4,000, e/D = 0.0001, and fguess = 1.