1 - Secant function file function x = secant(fun, x0, x1)...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
1/ Function file Colebrook function file function F= colebrook(f) d=0.03; R=1*10^6; F=(1/sqrt(f))+ 2*log((d/3.7)+ (2.51/R*sqrt(f))); end %Where is friction factor, is the relative roughness of the pipe %material, and is Reynolds number based on pipe diameter . You are supposed to solve this equation for using secant method.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Secant function file function x = secant(fun, x0, x1) xp = x0; fp = feval(fun,xp); x = x1; fx = feval(fun,x); n=5; for i = 1:n xn = x - fx * (x - xp) / (fx - fp); xp = x; fp = fx; x = xn; fx = feval(fun,x); end Script file secant( 'colebrook' ,0.006,0.007) ans = 0.0108...
View Full Document

This note was uploaded on 11/10/2010 for the course PGE 323K taught by Professor Lake during the Spring '08 term at University of Texas at Austin.

Ask a homework question - tutors are online