필터 지우기
필터 지우기

How do I stop this loop?

조회 수: 1 (최근 30일)
Salar
Salar 2016년 7월 12일
댓글: Salar 2016년 7월 27일
Hello,
I have a simple question, and I really appreciate it if you could please help me. I have a for loop, and I'd like to stop it when my calculated value exceeds a certain number, but my attempts haven't been successful. This is my code:
for i=1:100
[ f_YC,fp_YC] = FD_YC( ycI,mu,C );
[XN,iter]=NR(xn,f_YC,fp_YC);
xI=XN;
my = 1./((-xI+(1-mu).*(xI+mu)./((xI+mu).^2+ycI).^(3/2) +mu.*(xI-1+mu)./((xI-1+mu).^2+ycI.^2).^(3/2))./( ycI -ycI.*(1-mu)./((xI+mu).^2+ycI.^2).^(3/2)- ycI.*mu./((xI-1+mu).^2+ycI.^2).^(3/2)));
X = my .* ycI + XN;
if xI > .82;
break
end
end
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 12일
What is the problem?
Salar
Salar 2016년 7월 27일
I got it solved. Thank you anyways!

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2016년 7월 12일
That should stop it, if XN ever exceeds 0.82. Apparently it doesn't though. This is the way to find out why: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/ Perhaps since you don't pass I into any of the arrays or functions in the first two lines, the values never change. Not sure since we don't have those arrays or functions to check them.
  댓글 수: 1
Salar
Salar 2016년 7월 27일
Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by