You are on page 1of 1

%Mohammad Javad Aramideh 401668515

%Quiz 1
% M = eps/d;
M = [0.1 0.07 0.05 0.03 0.02 0.01 0.005 0.001 0.0001];
%Input from question
Re = [4e+3:1e+3:9e+3 1e+4:1e+4:9e+4 1e+5:1e+5:9e+5 1e+6:1e+6:1e+7];
disp('Following Calculation is According to Newton Method');
for i=1:length(M)
for j=1:length(Re)
%Also, We Can Use Input Function to Get User Data, But for this Solution,
%it won`t be Necessary;
g0 = 0.001;
df = 1;
%Absolute Error is Required, So We Should Use 'abs()';
while abs(df/g0) > 0.0001
A = 1/(sqrt(g0)); B = M(i)/3.7;
C = Re(j)*sqrt(g0); Ff = A + (0.86*log(B+(2.51/C)));
D = sqrt(g0^3); H = sqrt(g0);
dFf = (-0.5/D)+((-1.0793/(Re(j)*D))/(B+(2.51/C)));
df = -Ff/dFf; F(i,j) = g0+df; g0 = F(i,j);
end
end
end
% At Last, After Completing The Calculation, We Have to Plot This Curves, It Means
We
% Should Use 'Figure; Function and a Loop;
figure
for i = 1:6
axis([1e+3,1e+7,0.01,0.08]);
%For Display Curves in X-Logarithmic Coordinate, We Use 'Semilogx';
semilogx(Re,F);
%For Display Curves in Grid Plate, We Use 'grid on';
grid on;
%For Display Labels for each Axis, We Use 'x(or y)label';
xlabel('Re');
ylabel('f');
title('f - Re');
end

You might also like