decimal to binary conversion of an array
Ältere Kommentare anzeigen
i have an array a=[102, 2,3,201,8,9]
so when i convert it to binary each term has same length as
[ 0 1 1 0 0 1 1 0
0 0 0 0 0 0 1 0
0 0 0 0 0 0 1 1
1 1 0 0 1 0 0 1
0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 1]
but i want each term to become binary according to the size not with padded zero as 2 in binary is '10' not '0 0 0 0 0 0 1 0'
thanks in advance
4 Kommentare
Walter Roberson
am 1 Okt. 2019
Bearbeitet: Walter Roberson
am 1 Okt. 2019
Your current output data type is numeric array. What output data type are you hoping for? And what is the largest value that needs to be converted ?
PRAVEEN GUPTA
am 2 Okt. 2019
Walter Roberson
am 2 Okt. 2019
Numeric only
Sorry, that is not possible in MATLAB. In MATLAB, numeric arrays must always have the same number of columns in each row.
If you had wanted cell array of character vectors, or string array, or cell array of numeric vectors, then those would be possible.
PRAVEEN GUPTA
am 2 Okt. 2019
Akzeptierte Antwort
Weitere Antworten (1)
PRAVEEN GUPTA
am 2 Okt. 2019
0 Stimmen
Kategorien
Mehr zu Numeric Types finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!