how to find the number of 1 in a single column?
4 次查看(过去 30 天)
显示 更早的评论
My input is
0 0 0 0 1 0 0 1 1 0 0 0 1 0
I should find how many 1 is present
2 个评论
回答(6 个)
Matt Tearle
2012-9-5
编辑:Matt Tearle
2012-9-5
idx = find(all(bsxfun(@eq,x,y),2));
where x is your matrix and y is your test vector (eg y = x(1,:), in your example). For example
x = randi(4,1000,5);
y = x(3,:);
idx = find(all(bsxfun(@eq,x,y),2))
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!