Filter löschen
Filter löschen

Find and summarize values in matrix WITHOUT loop

2 Ansichten (letzte 30 Tage)
Sebastian Daneli
Sebastian Daneli am 11 Mär. 2020
Kommentiert: Sebastian Daneli am 11 Mär. 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?

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 11 Mär. 2020
M=[1 2;1 1];
sum(M==1,1)

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by