Check an array of values if within an upper and lower limit
이전 댓글 표시
I am trying to do the same thing as the following example but checking an array of numbers and not just x. However it is not working. can someone help?
x = 10;
minVal = 2;
maxVal = 6;
if (x >= minVal) && (x <= maxVal)
disp('Value within specified range.')
elseif (x > maxVal)
disp('Value exceeds maximum value.')
else
disp('Value is below minimum value.')
end
채택된 답변
추가 답변 (1개)
KSSV
2018년 10월 15일
minVal = 2;
maxVal = 6;
if any(x >= minVal) && any(x <= maxVal)
disp('Value within specified range.')
elseif any(x > maxVal)
disp('Value exceeds maximum value.')
else
disp('Value is below minimum value.')
end
댓글 수: 3
Ayman Fathy
2018년 10월 15일
편집: Ayman Fathy
2018년 10월 15일
Ayman Fathy
2018년 10월 15일
Ayman Fathy
2018년 10월 15일
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!