What in the world is going on with my loop? Matlab getting hang up?

Resubmitted question in proper format. Worked on this a bit more with no luck. Need to make the Left side of the equation (LS) equal to the right side (RS), by iterating on the value of SSi.Thanks.
Di = 0.3750, Do =0.6667, k =0.1050, n = 0.5000, U = 3.7370, YP = 10.4500
SSi = 0.01;
RS = ((SSi- YP)^((n+1)/n))*(3*n/(1+2*n))*(SSi+(n/(n+1))*YP)/(k^(1/n)*SSi^2);
LS = 12*U/(Do-Di);
while abs(RS-LS)< 0.1
SSi = SSi + 0.01
RS = ((SSi- YP)^((n+1)/n))*(3*n/(1+2*n))*(SSi+(n/(n+1))*YP)/(k^(1/n)*SSi^2);
end

1 Comment

Please learn to use the {} code button.
When you edit the question, select the block of code, then click the code button. That will make your code readable, instead of one unreadable line.

Sign in to comment.

Answers (1)

It would help if you format your code, but from what I see you have a while loop on the condition
e > 0.001
yet the body of your while loop is:
m = m + 0.01;
which does not change 'e' at all so you have an infinite loop because if e never changes it will always be > 0.001, assuming it starts off by satisfying the condition.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Asked:

on 30 Sep 2015

Edited:

on 5 Oct 2015

Community Treasure Hunt

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

Start Hunting!