Using IF to remove upper and lower boundaries

조회 수: 2 (최근 30일)
Tom
Tom 2012년 10월 29일
Within a FOR loop, I can successfully implement a single IF statement to prevent either the upper or lower values from being manipulated like so:
if (theta1 > 0.7297)
continue
end
However every attempt I have made to remove both upper and lower values has failed. Can anyone explain what is wrong with this:
if (theta1 > 0.7297)
else (theta1 < -0.7297)
continue
end
Thanks.

채택된 답변

Arthur
Arthur 2012년 10월 29일
So you want to continue if theta1 > 0.7297 or if theta < -0.7297? Then you could test for both in the if statement:
if (theta1 > 0.7297) || (theta1 < -0.7297)
continue
end
  댓글 수: 1
Tom
Tom 2012년 10월 29일
Thanks. That link was very helpful.

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

추가 답변 (1개)

Thomas
Thomas 2012년 10월 29일
편집: Thomas 2012년 10월 29일
I think this is what you need
if (theta1 > 0.7297 || theta1 < -0.7297)
continue
end
You can enter both conditions in the single If statement.
  댓글 수: 1
Tom
Tom 2012년 10월 29일
Thankyou very much, that's exactly right!

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by