How can I have matlab identify if a specific element is repeated a specific number of times?
조회 수: 2 (최근 30일)
이전 댓글 표시
Lets say a I have a 10 by 10 matrix with a random combination of numbers. So I want MATLAB to check a specific number is repeated a specific times. For example, what can I type if I want MATLAB to check if the number 1 is repeated 3 times in the 10 by 10 matrix?
댓글 수: 0
답변 (2개)
Muruganandham Subramanian
2012년 12월 12일
편집: Muruganandham Subramanian
2012년 12월 12일
try this:
find(A==1)
If you would like to know more,
>>help find
댓글 수: 3
Muruganandham Subramanian
2012년 12월 12일
편집: Muruganandham Subramanian
2012년 12월 12일
If you need to check for no.of times, assign a variable
c=find(A==1)
size(c)
Walter Roberson
2012년 12월 12일
You can apply size() to an expression
size(find(A==1))
size() is, either way, going to return a vector of dimensions. Which of those elements should George check? Will the answer vary in newer MATLAB versions which are changing the rules about whether various functions return row outputs or column outputs?
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!