I am trying to solve a iterative design problem using programming.
Design Problem
Determine Flow depth (d) for following conditions:
Diameter of sewer (D) = 200mm
Discharge through sewer (Q) = 122.3 LPM
Sewer Material = Concrete, Manning's coefficient = 0.013
Longitudinal slope = 1 in 1000.
The algorithm is:
i. Assume a value of a, which is in between 0 to 360.
ii. Calculate the other parameters ar, A, P, R, Qi. (Formulas are as mentioned in code).
iii. Compare that Qi to Qd (Pre defined as numeric value), if both are same then proceed for printing calculated variables, if not then repeat the process again until Qi = Qd.
I had tried this code, I used for loop but it is not working, and I tried while loop, it is struck in calculations.
D = 200; %Diameter of sewer in mm
D = D/1000; %dia in meter
n = 0.013; %Manning's coefficient
S0 = 1/1000; %Bed slope
Q = 122.3; %LPM
Qd = Q/(1000*60); % Discharge in LPM to Cumecs
n = 360;
for a = 1:1:n
ar = a*0.0174; %theta in radians
A = ((D^2)/8)*(ar-sin(a));
P = (ar*D)/2;
R = A/P;
Qi = (A/n)*(R^(2/3))*sqrt(S0);
while Qi == Qd
fprintf('Area of flow is %d \n',A);
fprintf('Discharge is %.5f \n', Qi);
end
while Qi~ Qd
a= a+1 && a<360;
end
end

 Respuesta aceptada

Torsten
Torsten el 28 de En. de 2022

0 votos

Change sin(a) to sind(a).
Further Qi will never be exactly Qd.
I suggest you print Qi-Qd over a and see if it intersects the a-axis.
For this, change the line
Qi = (A/n) ...
to Qi(a) = (A/n)...
and write
plot((1:360),Qi)
after the for loop.

1 comentario

saiprasad bodapati
saiprasad bodapati el 29 de En. de 2022
I think Qi == Qd, is where it went wrong, can i some how define matlab to consider only upto 4 decimal digits in comparision. can i define it ...??

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Mathematics and Optimization en Centro de ayuda y File Exchange.

Productos

Versión

R2020b

Preguntada:

el 28 de En. de 2022

Comentada:

el 29 de En. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by