Must submit complete MATLAB code to compute the following. (Using f zero) Consid
ID: 2903334 • Letter: M
Question
Must submit complete MATLAB code to compute the following.
(Using f zero) Consider the Colebrook equation for the friction factor in a fully developed pipe flow 1/square root of f=-2 log 10 (e/D/3.7 +2.51 /ReD square root of f) where f is the Darcy friction factor, e/D is the relative roughness of the pipe material, and Re is the Reynolds number based on a pipe diameter D. Use f zero to find the friction factor f corresponding to parameter values e/D = 0.0001 and ReD = 3 x 10^5. Use a tolerance of 10^-8 and write the root you find to the file friction _f actor .dat. Hint: Use the function optimset to set up the tolerance TolX.Explanation / Answer
k=1e-4;
%% k=epsilon/D
Red=3e+5;
x0=0.01;
G=@(f)((1./sqrt(f))+2*log10((k/3.7)+(2.51./(Red*sqrt(f)))));
option=optimset('TolX',1e-8);
x1=fzero(G,x0,option);
fileId=fopen('friction_factor.dat','w');
fprintf(fileId,'%7.5f',x1);
fclose(fileId);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.