Find and summarize values in matrix WITHOUT loop

2 ビュー (過去 30 日間)
Sebastian Daneli
Sebastian Daneli 2020 年 3 月 11 日
コメント済み: Sebastian Daneli 2020 年 3 月 11 日
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)
  1 件のコメント
Sebastian Daneli
Sebastian Daneli 2020 年 3 月 11 日
Wow, that was fast. Tank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by