Alrighty, so I need to code the bisection method to evaluate a fluid dynamics equation.
I've been coding MATlab for ohhhhhh about 3 weeks now and this is wayyyyy above my skill-set.
but here's what I got, I've gotten it to actually work but gives the wrong answer, I've gotten it to run for what seems like an infinite loop
and i've gotten it to loop once and never again, I'm stuck and I'm just not educated enough to fix it.
Also built in MATlab functions are a no-no so it has to be the old school no shortcut's way to do things. no dsolve or syms or what have you.
Please help!
clc; clear all;
d=3.612;
v=20;
m=.00001825;
l=20;
D=.5;
n=.0001;
Re=(d*v*D)/m;
a=.000001;
b=.999999;
EA=.001;
fa=(-2.0*log10(((n/D)/3.7)+(2.51/(Re*sqrt(a)))))-(1/(sqrt(a)));
fb=(-2.0*log10(((n/D)/3.7)+(2.51/(Re*sqrt(b)))))-(1/(sqrt(b)));
while abs((b-a)/b)>EA
c=(a+b)/2;
fc=(fa+fb)/2;
if fa*fc<0
b=c;
fb=fc;
elseif fb*fc<0
a=c;
fa=fc;
else
break
end
end
f=fc;
fprintf('f= %8.6d',f);