Using a WHILE loop for a trial and error solution.
Mostrar comentarios más antiguos
Respuestas (1)
Image Analyst
el 1 de Mzo. de 2014
Editada: Image Analyst
el 1 de Mzo. de 2014
You can't use this invalid syntax:
(0.05*Cm)<Pn<(0.05*abs(Cm))
You have to do it as two separate comparisons:
(0.05*Cm)<Pn && Pn <(0.05*abs(Cm))
Fix that and try it again.
Also, you tagged it as "infinite loop" - that's why robust code (like I write) always has a failsafe in there. For example you could have a loop counter and if it exceeds some number that you expect it to never exceed, bail out of the loop
counter = 1;
while someCondition
% code
counter = counter + 1;
if counter >= 5000 % Some big number
break; % Fail safe - something went wrong so bail out!!!
end
end % of while loop.
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!