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

 채택된 답변

Torsten
Torsten 2022년 1월 28일

0 개 추천

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

saiprasad bodapati
saiprasad bodapati 2022년 1월 29일
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 ...??

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2022년 1월 28일

댓글:

2022년 1월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by