Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How do I count to occurences of a number in an unsanitized array

1 vue (au cours des 30 derniers jours)
Joel Abrahams
Joel Abrahams le 19 Juil 2017
Clôturé : MATLAB Answer Bot le 20 Août 2021
Say I have cell A, with values:
0
0
1
[0; 1; 0]
1
Now I want to count the occurences of 1 is this matrix, and [0; 1; 0] should be ignored.
However, when I do:
amount_correct = sum(A == 1);
I get an error as soon as it arrives at [0; 1; 0].
I however simply want it to give as output 0 and move on to the next element of the array till I get to the end.
The eventual output should be 2.

Réponses (0)

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by