If Elseif statement problem
이전 댓글 표시
What is wrong with this the debug is stopping eventhough my d_g value is between 1 and 60. Any suggestion?
if Fr>0.8 % A-W is not suitable for Fr>0.8
disp('Ackers white not suitable for Fr>=0.8')
elseif Fr<0.8
if (d_g>1) && (d_g<60)
A_aw=0.23*d_g^(-0.5)+0.14;
C_aw=10^(2.86*log10(d_g)-(log10(d_g))^2-3.53);
n_aw=1-0.56*log10(d_g);
m_aw=9.66/d_g+1.34;
elseif d_g>60
A_aw=0.17;
C_aw=0.025;
n_aw=0;
m_aw=1.5;
else
disp('Check your input for d_35 again')
end
end
댓글 수: 6
Adrian Dronca
2013년 1월 18일
Maybe you should provide more code or what values you have for the variables when it gets stuck. I ran the code with Fr = 0.6 and d_g = 30 and it is working fine.
Jan
2013년 1월 18일
What does "the debug is stopping" exactly mean?
Image Analyst
2013년 1월 18일
편집: Jan
2013년 1월 18일
@Meh: If you learn how to use the debugger, and step through your code one line at a time, you'll discover your error. This is what virtually everyone else does, and quite successfully. Click this to see the Video Tutorial on debugging
Meh
2013년 1월 18일
Jan
2013년 1월 18일
@IA: I'd vote for it, if you post this as an answer.
I used " dbstop if error " : the loop continues until else if Fr<0.8 but, eventhough the d_g value is between 1 and 60 A_aw, C_aw, n_aw_and m_aw are not being calculated.
Why would "dbstop if error" stop there? What error was produced to trigger the stop, and what was the value between 1 and 60 that d_g held at that moment?
답변 (1개)
In addition to my questions above, is it possible that d_g is exactly 1 or 60? Currently, you only test whether it lies strictly between them.
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!