Count number 1 in the row
Show older comments
Dear all, I have this range:
x=[0 0 0 1 0 1 0 0]
I want to count number 1 in this row. Could you help me? Thanks.
Accepted Answer
More Answers (3)
Gennaro Arguzzi
on 11 May 2017
Edited: Gennaro Arguzzi
on 11 May 2017
0 votes
z=[0 0 0 1 0 1 0 0];
a=length(z);
b=0;
for i=1:a
if(z(i)==1)
b=b+1;
end
end
KSSV
on 11 May 2017
x=[0 0 0 1 0 1 0 0] ;
nnz(x)
find(x==1)
x(x==1)
Aamer Ejaz
on 20 Feb 2020
length(find(X)==1)
1 Comment
madhan ravi
on 20 Feb 2020
length(find(X==1))
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!