function similar to count

조회 수: 5 (최근 30일)
SSG_newbiecoder
SSG_newbiecoder 2017년 12월 26일
댓글: SSG_newbiecoder 2017년 12월 26일
Is there any function similar to count that can be used in an array of 1's,-1's and 0's to count the number of 1's present in a particular range?
  댓글 수: 1
Birdman
Birdman 2017년 12월 26일
Check my answer.

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

채택된 답변

Birdman
Birdman 2017년 12월 26일
One approach:
A=randi([-1 1],1,100);%random data for -1,0 and 1
cnt=sum(ismember(A,1));%counts the number of 1 in array A

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by