Borrar filtros
Borrar filtros

How to detect certain values within the data?

2 visualizaciones (últimos 30 días)
Jinho YOo
Jinho YOo el 7 de Mzo. de 2019
Respondida: madhan ravi el 8 de Mzo. de 2019
Hello,
I am supposed to find certain value in the data set and I have to find the sum of number of times I found that certain value.
For instance, I have matrix 860 * 920 double and it is made of combinations of number 0, 1, 2.
Every time I detect 2, I need to count it and display the total count.
Im trying to use for loop.
How do I detect the certain values in matrix and add the number of detection?
Thank you.

Respuestas (2)

Kevin Phung
Kevin Phung el 7 de Mzo. de 2019
%let M be your 860*920 matrix
number = 2; %value you are looking for
total_count = sum(sum(M==number))
no loop needed

madhan ravi
madhan ravi el 8 de Mzo. de 2019
nnz(matrix==2)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by