What in the world is going on with my loop? Matlab getting hang up?
Mostrar comentarios más antiguos
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 comentario
John D'Errico
el 30 de Sept. de 2015
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.
Respuestas (1)
Adam
el 30 de Sept. de 2015
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.
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!