I cannot figure out why the while loop of the A location section is infinite. Can someone help me out. My file is attached
조회 수: 1 (최근 30일)
이전 댓글 표시
There is no error code, the program just continues to run. The part I am struggling with starts at line 93 of my code.
댓글 수: 0
답변 (1개)
Image Analyst
2014년 11월 30일
You did not use the debugger. I can tell because when I got to the line
while abs(errori)>0.01
I noticed that errori is an array, not a single scalar number, and if you saw that loud alarm bells would have gone off in your head. First, take off the semicolons from the lines of code where you assign errori so you can see what they are.
This is also good example of why you need a failsafe to write robust code. You did not put a loop counter on your while statement so it's possible that you could have an infinite loop. Prevent that with a counter:
counter = 1;
while errori < 0.01 && counter < 1000 % or whatever
counter = counter + 1; % Increment failsafe.
% more code....
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 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!