Count number 1 in the row
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
更多回答(3 个)
Gennaro Arguzzi
2017-5-11
编辑:Gennaro Arguzzi
2017-5-11
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!