필터 지우기
필터 지우기

How to count a specific value from column to column

조회 수: 2 (최근 30일)
Jonas Damsbo
Jonas Damsbo 2019년 1월 3일
편집: madhan ravi 2019년 1월 3일
Hey
Maybe a simple question. But if I have a vector lets say 15x1 vector like:
[1 1 1 0 1 0 0 1 0 0 1 0 1 0 1]
Now I want to count the number 1 in range of 5 columns so I get a new vector:
[4 1 3]
Anyway to do that?

채택된 답변

madhan ravi
madhan ravi 2019년 1월 3일
편집: madhan ravi 2019년 1월 3일
a=[1 1 1 0 1 0 0 1 0 0 1 0 1 0 1];
Result=sum(reshape(a',5,[]))
Gives:
Result =
4 1 3
  댓글 수: 2
madhan ravi
madhan ravi 2019년 1월 3일
Jonas Damsbo's comment moved here:
Thank you! Thats work!
madhan ravi
madhan ravi 2019년 1월 3일
Anytime :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by