I have an array and I want to check if any of the array elements doesn't satisfy a certain condition.
조회 수: 1 (최근 30일)
이전 댓글 표시
I have an array and I want to check if any of the array elements doesn't satisfy a certain condition.
For example:
A = [ 5 8 1 2 7 9 6]
and I want to find out the number of elements below 3, which are 1 and 2 in this situation, how can i find it for larger arrays?
댓글 수: 0
채택된 답변
Jan
2021년 11월 11일
A = [ 5 8 1 2 7 9 6];
isLowerThan3 = A < 3
A(isLowerThan3)
댓글 수: 2
Jan
2021년 11월 11일
I do not understand the problem. If you want the numbers smaller than 3, [1, 2] is the correct answer. Why do you want the 2 only? Are you looking for the largest number smaller than 3? Or the number which is nearest to 3?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!