I am writing a code that keep giving error message.

function f=DarcyFricFact(D,E,Re)
% Calculatre Friction factor
% f: is friction
% E :pipe roughness (for cast iron, 0.010")
% D: pipe diameter in inches
% Re: Reynolds number
% For loop will help use to write the program
%%%%%%Argument
D=[2 5 10];
Re=(4000:400000);
E=0.01;
f1=zeros(1,350000);
f2=zeros(1,350000);
f3=zeros(1,350000);
n=1
Num=length (Re);
k=1;
f=zeros(k,Num);
for n=1:Num;
a = 2/log(10)
b = (E./D)/3.7;
d=log(10)*Re(n)/5.02
s=b*d+log(d);
q=s.^(s/(s+1));
g=b*d+log(d./q);
z=log(q/g);
DLA=z*(g/(g+1));
DCFA=DLA.*(1+(z/2)/((g+10.^(2) + (z/3).*(2.*g-1))));
f(k)=(a*((log(d/q)+DCFA))).^(-2);
end
end

2 Comments

There are many problems. Replacing
DCFA=DLA.*(1+(z/2)/((g+10.^(2) + (z/3).*(2.*g-1))));
by
DCFA=DLA.*(1+(z/2)./((g+10.^(2) + (z/3).*(2.*g-1))));
fixes the first. See Debug a MATLAB Program

Sign in to comment.

Answers (0)

Categories

Find more on Fluid Dynamics in Help Center and File Exchange

Asked:

on 8 Jul 2016

Commented:

on 8 Jul 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!