how to convert a single row matrix into an n bit number
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am given a numerical array, a = [0 0 1 0 1 0 1]. i have to transform it into n bit number, n = column number,
a = 0010101.
sprintf and other functions ignore the preceding zeros, which isn't helpful.
0 commentaires
Réponses (1)
Image Analyst
le 3 Juil 2021
Try this:
a = [0 0 1 0 1 0 1]
str = sprintf('%d', a)
num = bin2dec(str)
a =
0 0 1 0 1 0 1
str =
'0010101'
num =
21
0 commentaires
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!