logical operation on matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
(Return logical 0 or 1) if matrix A contains ten values between 500 and 600.
A=[1 2 3;4 5 6; 4 5 2]
A(A>[1:2:6])=true %SMALL NUMBERS FOR EXAMPLE
댓글 수: 0
채택된 답변
DGM
2022년 3월 8일
I'm going to assume that the text question is what you're after:
A = randi([100 999],10,10) % a bunch of integers
mk = A>=500 & A<=600 %find locations in the specified range
has10inrange = nnz(mk)>=10 % are there at least 10 values in the range?
댓글 수: 1
Image Analyst
2022년 3월 8일
Or if you want to know if "A contains ten values between 500 and 600"
has10inRange = nnz(mk) == 10 % has10inRange is true if there are exactly 10 values in the range.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!