Help with Matrix logic and indexing
古いコメントを表示
how do i look through a matrix and count how many times this conditon occuers ( >= 40 & <= 50)
回答 (2 件)
Image Analyst
2022 年 3 月 27 日
Use sum():
mask = m >= 40 & m <= 50; % Works for vectors or matrices where m is your array.
count = sum(mask(:))
2 件のコメント
Trying to Try
2022 年 3 月 27 日
Image Analyst
2022 年 3 月 27 日
Can you then click the "Accept this answer" link? Thanks in advance. 🙂
Stephen23
2022 年 3 月 27 日
cnt = nnz(m>= 40 & m<= 50)
カテゴリ
ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!