how to find the number of 1 in a single column?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (6)
Sivakumaran Chandrasekaran
am 5 Sep. 2012
Matt Tearle
am 5 Sep. 2012
Bearbeitet: Matt Tearle
am 5 Sep. 2012
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 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!