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
Image Analyst 2022 年 3 月 27 日

1 投票

Use sum():
mask = m >= 40 & m <= 50; % Works for vectors or matrices where m is your array.
count = sum(mask(:))

2 件のコメント

Trying to Try
Trying to Try 2022 年 3 月 27 日
Thank you so much ive wasted to much of my day on this one
Image Analyst
Image Analyst 2022 年 3 月 27 日
Can you then click the "Accept this answer" link? Thanks in advance. 🙂

サインインしてコメントする。

Stephen23
Stephen23 2022 年 3 月 27 日

0 投票

cnt = nnz(m>= 40 & m<= 50)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

質問済み:

2022 年 3 月 27 日

回答済み:

2022 年 3 月 27 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by