how to find the total number of ones from the given input...
1 次查看(过去 30 天)
显示 更早的评论
Sivakumaran Chandrasekaran
2013-11-20
评论: Sivakumaran Chandrasekaran
2013-11-20
suppose my input is a=1,b=1,c=1,d=0... my objective is to find count the total number of ones.. how to find.. which method is good to follow
0 个评论
采纳的回答
Azzi Abdelmalek
2013-11-20
a=1,
b=1,
c=1,
d=0
Instead of using all these variables, you can use just one array
v=[a b c d ]
To count number of ones
no=sum(v)
2 个评论
Image Analyst
2013-11-20
or sum(v==1) just in case there are any integers other than 0 and 1 in there.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!