Find and summarize values in matrix WITHOUT loop

조회 수: 3 (최근 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)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by