how to convert a single row matrix into an n bit number
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 3 Jul 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 Comments
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!