Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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

3 visualizaciones (últimos 30 días)
Joel Abrahams
Joel Abrahams el 19 de Jul. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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.

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by