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

1 vue (au cours des 30 derniers jours)
vetri veeran
vetri veeran le 13 Déc 2014
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.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 13 Déc 2014
Modifié(e) : Azzi Abdelmalek le 13 Déc 2014
x=repmat(1:4,4,1) % Example
out=sum(x(:)==1)
%or
out=nnz(x==1)

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by