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 comentarios

per isakson
per isakson el 8 de Jul. de 2016
Editada: per isakson el 8 de Jul. de 2016
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
PaulBan
PaulBan el 8 de Jul. de 2016
Thanks

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Fluid Dynamics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 8 de Jul. de 2016

Comentada:

el 8 de Jul. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by