Assign values to a string in Matlab

2 visualizaciones (últimos 30 días)
Laura Paola Goyeneche Gomez
Laura Paola Goyeneche Gomez el 16 de Oct. de 2019
Respondida: Stephen23 el 16 de Oct. de 2019
For example I have:
X ='abcaaabc';
How can I get it like
Y= [a b c a a a b c];
and
Y1= [0 1 2 0 0 0 1 2]

Respuestas (2)

Fangjun Jiang
Fangjun Jiang el 16 de Oct. de 2019
  1 comentario
Fangjun Jiang
Fangjun Jiang el 16 de Oct. de 2019
Editada: Fangjun Jiang el 16 de Oct. de 2019
You can't have the Y you want. Maybe Y=[X(:)], or Y=transpose(string(X'))

Iniciar sesión para comentar.


Stephen23
Stephen23 el 16 de Oct. de 2019
>> X = 'abcaaabc';
>> Y = num2cell(X)
Y =
'a' 'b' 'c' 'a' 'a' 'a' 'b' 'c'
>> Y1 = X-97
Y1 =
0 1 2 0 0 0 1 2

Categorías

Más información sobre Data Types 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