Using a WHILE loop for a trial and error solution.
显示 更早的评论
回答(1 个)
Image Analyst
2014-3-1
编辑:Image Analyst
2014-3-1
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!