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!