Array of 1 and 0 to decimal
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hg
am 19 Apr. 2016
Bearbeitet: John D'Errico
am 19 Apr. 2016
How to convert array with 1's and 0's (array A) to decimal (array B)?
A = [1 0 0 1 0 0 1 1; 0 0 0 0 1 1 1 1; 1 0 1 0 1 0 1 0 ];
B = [147;15;170];
0 Kommentare
Akzeptierte Antwort
John D'Errico
am 19 Apr. 2016
Bearbeitet: John D'Errico
am 19 Apr. 2016
B = bin2dec(char(A + '0'))
B =
147
15
170
0 Kommentare
Weitere Antworten (1)
Azzi Abdelmalek
am 19 Apr. 2016
A = [1 0 0 1 0 0 1 1; 0 0 0 0 1 1 1 1; 1 0 1 0 1 0 1 0 ];
out=A*2.^(size(A,2)-1:-1:0)'
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Types finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!