Convert string to a row matrix

1 visualización (últimos 30 días)
Sadia
Sadia el 15 de Jul. de 2012
hay i want to convert a string into a row matrix
wat i have: '01011100100000100001010110010111'
wat i need: [0 1 0 1 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 1 0 1 1 0 0 1 0 1 1 1]

Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Jul. de 2012
row_matrix = YourString - '0';

Más respuestas (2)

Azzi Abdelmalek
Azzi Abdelmalek el 16 de Jul. de 2012
a= '01011100100000100001010110010111'
b=~isspace(regexprep(a, '0',' '))
  2 comentarios
Walter Roberson
Walter Roberson el 16 de Jul. de 2012
Clunky :(
Azzi Abdelmalek
Azzi Abdelmalek el 17 de Jul. de 2012
Editada: Azzi Abdelmalek el 17 de Jul. de 2012
my aswers is only valid for binary. i know it does'nt work for other numbers

Iniciar sesión para comentar.


khaled DAWOUD
khaled DAWOUD el 17 de Jul. de 2012
Editada: khaled DAWOUD el 17 de Jul. de 2012
a= '01011100100000100001010110010111'
% b is the matrix for the a.
for k=1:1:size(a,2)
b(k)=str2num(a(k));
end

Categorías

Más información sobre Encryption / Cryptography en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by