how can i calculate how many number of times that 1 occurs.

4 visualizaciones (últimos 30 días)
I have an array like this
x =
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
how can i calculate how many number of times that 1 occurs.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 13 de Dic. de 2014
Editada: Azzi Abdelmalek el 13 de Dic. de 2014
x=repmat(1:4,4,1) % Example
out=sum(x(:)==1)
%or
out=nnz(x==1)

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by