function similar to count
5 次查看(过去 30 天)
显示 更早的评论
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?
采纳的回答
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 Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!