Help with Colebrook equation and f zero command.
2 views (last 30 days)
Show older comments
I am trying to do a problem with the colebrook equation in which I have to find the roots of the equation to find "f". I am trying to use the fzero command along with a function file, but it is not working. How do I do this?
function f = fricfactor(f) Re = linspace(10e4,10e7,31); f = (1/sqrt(f))-2*log10(Re*sqrt(f))-0.8; end
fcw = fzero(@fricfactor,[0 1]);
0 Comments
Accepted Answer
Torsten
on 7 Nov 2014
f=@(x)(1/sqrt(x)-2*log10(Re*sqrt(x))-0.8);
Re=10000;
Delta_Re=200;
for i=1:20
fcw(i)=fzero(f,[1e-8 1]);
Reynolds(i)=Re;
Re=Re+Delta_Re;
end
Best wishes
Torsten.
3 Comments
More Answers (1)
Torsten
on 7 Nov 2014
Re=10000;
f=@(x)(1/sqrt(x)-2*log10(Re*sqrt(x))-0.8);
fcw = fzero(f,[1e-8 1]);
If you want to determine fcw for different Reynolds numbers, you will have to do that in a for Loop.
Best wishes
Torsten.
See Also
Categories
Find more on Partial Differential Equation Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!