Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

If Elseif statement problem

Asked by Meh on 18 Jan 2013

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 Comments

Meh on 18 Jan 2013

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.

Jan Simon on 18 Jan 2013

@IA: I'd vote for it, if you post this as an answer.

Matt J on 18 Jan 2013

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?

Meh

Products

No products are associated with this question.

1 Answer

Answer by Matt J on 18 Jan 2013
Edited by Matt J on 18 Jan 2013

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.

0 Comments

Matt J

Contact us