How can I have matlab identify if a specific element is repeated a specific number of times?
1 次查看(过去 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!