how to find the total number of ones from the given input...
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sivakumaran Chandrasekaran
le 20 Nov 2013
Commenté : Sivakumaran Chandrasekaran
le 20 Nov 2013
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 commentaires
Réponse acceptée
Azzi Abdelmalek
le 20 Nov 2013
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 commentaires
Image Analyst
le 20 Nov 2013
or sum(v==1) just in case there are any integers other than 0 and 1 in there.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!