want to stop the value at certain value in for loop

조회 수: 4 (최근 30일)
abdalrhman hassan
abdalrhman hassan 2016년 10월 22일
댓글: Geoff Hayes 2016년 10월 23일
hey guys when i run the program it keep show me the negative value and i only want it the positive and less error thank you

채택된 답변

Geoff Hayes
Geoff Hayes 2016년 10월 22일
abdalrhman - if you want to exit out of your loop once the tolerance is less than zero, then put in a condition to do so
for EJ=EJ+.015:.01:E1-.01
Q1=sqrt((E1-EJ)/R1);
Q2=sqrt(abs((E2-EJ))/R2);
Q3=sqrt((EJ-E3)/R3);
tol=Q1-Q2-Q3l
EJ;
if tol < 0
break; % exit loop since tolerance is now negative
end
tolnew=tol;
end
  댓글 수: 1
Geoff Hayes
Geoff Hayes 2016년 10월 23일
abdalrhman's answer moved here
Thank you that was helpful :D

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by