Find and summarize values in matrix WITHOUT loop

2 次查看(过去 30 天)
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?

采纳的回答

Ameer Hamza
Ameer Hamza 2020-3-11
M=[1 2;1 1];
sum(M==1,1)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by