binary matrix to decimal number

1 visualización (últimos 30 días)
Abduellah Elbakoush
Abduellah Elbakoush el 21 de En. de 2022
Comentada: Abduellah Elbakoush el 21 de En. de 2022
I have binary matrix the dimensions of matrix (1*8) like this
1 0 1 1 0 0 1 0
I want to put that matrix into another matrix the dimensions of new matrix is ( 1*1) like this
10110010
then I want to conver into decimel number like this
178
Can you help me to do this problem

Respuesta aceptada

Walter Roberson
Walter Roberson el 21 de En. de 2022
A = [1 0 1 1 0 0 1 0 ]
A = 1×8
1 0 1 1 0 0 1 0
bin2dec(char(A+'0'))
ans = 178

Más respuestas (1)

Simon Chan
Simon Chan el 21 de En. de 2022
Try this:
A = logical([1 0 1 1 0 0 1 0]);
B = bin2dec(num2str(A))
  1 comentario
yanqi liu
yanqi liu el 21 de En. de 2022
a = [1 0 1 1 0 0 1 0 ];
b = strrep(num2str(a), ' ', '')
b = '10110010'
c = bin2dec(b)
c = 178

Iniciar sesión para comentar.

Categorías

Más información sobre Import, Export, and Conversion en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by