Find and summarize values in matrix WITHOUT loop

3 visualizaciones (últimos 30 días)
Sebastian Daneli
Sebastian Daneli el 11 de Mzo. de 2020
Comentada: Sebastian Daneli el 11 de Mzo. de 2020
Let's say that I have a matrix M=[1 2;1 1], and I need to find all the 1:s in each culumn, and then summerize them in a vector as v=[2 1]. Is this possible without a loop?

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 11 de Mzo. de 2020
M=[1 2;1 1];
sum(M==1,1)

Más respuestas (0)

Categorías

Más información sobre MATLAB 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