how do i verify input is only zeros and 1's
Afficher commentaires plus anciens
i am trying to figure out how to check if a number entered by a user is only zeros and ones (checking if its binary). I am not allowed to use a table or matrix
this is what I have, but doesn't seem to work
number = input('please enter a number:', 's')
if all(ismember(number,['0' '1'])) fprintf('this is a binary number.'); else fprintf('this is not a binary number.'); end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!