Solve Command On Colebrook Equation
4 views (last 30 days)
Show older comments
Hello...I am attempting to plot the colebrook, bruus, and haaland equations on a loglog scale for a homework assignment. I currently have my script working properly for the bruus and haaland equations but my colebrook equation section is not working well and I'm a little bit stuck on why not. For those who may not know, the colebrook equation cannot be solved through Algebra and must be solved iteratively. And so, after discussion with my professor, he's told me to use the MATLAB solve command. I have done this (I believe) correctly.
Essentially, for this equation, I need the f values within the c equation and these are to be saved as C1. this should be a 1x1000 double (I believe) due to my bruus and haaland values.
Would someone please be able to look at my code and help me understand what is wrong?
Thank you!
clear
clc
close all
format short
Re = 10^4:100000:10^8;
%%Colebrook
syms f;
c =@(x) -2*log((x/3.7)+(2.51./(Re*sqrt(f)))) == 1/sqrt(f);
%%Bruus
fB = @(x) .25*((log((x/3.7)+(5.74./(Re).^.9)))).^-2;
%%Haaland
fH = @(x) (1./(-1.8*log((x/3.7)^1.11+(6.9./Re)))).^2;
%%Figures
%Figure 1
eD1 = 0;
C1 = solve(c,f);
B1 = fB(eD1);
H1 = fH(eD1);
figure;
loglog(Re,C1,':')
hold on
loglog(Re,B1,'r')
hold on
loglog(Re,H1,'--')
title('f vs. Re e/D = 0');
xlabel('Re');
ylabel('f');
legend('Colebrook','Bruus','Haaland');
grid on
0 Comments
Answers (0)
See Also
Categories
Find more on Fluid Dynamics 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!