How to count number of states in array?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I want to count number of states in vector, each number represent a state: Ex.
A = [1;1;0;1;0]
B = [2;2;1;0;1]
C = [1;1;1;1;1]
A has two states 1 and 0 ==> k=2, B has three states 1, 2, 0 ==> k=3, and C has zero state ==> k=0. how can I write a proforma to define k (number of states)?
댓글 수: 3
Walter Roberson
2017년 6월 4일
If necessary, my suggestion could be followed by testing if the result was 1, and if so then change it to 0.
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!