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!