If Else Statements With Conditions

조회 수: 1 (최근 30일)
BM
BM 2018년 7월 2일
편집: OCDER 2018년 7월 2일
I am looking to write an 'ifelse' statement with the conditions such as the following:
a+7+b <= index <= c
where a, b, and c are variables that change depending on how other parameters change in the program. Simply put, if my index is equal to or greater than a+7+b, or less than or equal to c.

채택된 답변

OCDER
OCDER 2018년 7월 2일
편집: OCDER 2018년 7월 2일
Did you want "OR" () or "AND" (&&)?
if a+7+b <= index || index <= c %If you want OR, here it is. If you want AND, use && instead of ||
... %your code
else
... %your alternative code
end

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by