Converting a String to an Array

7 visualizaciones (últimos 30 días)
Dominic Lawson
Dominic Lawson el 14 de Mzo. de 2011
Hello!
I was wondering how to go about converting a string into an array like
x = [1 2 3 1 2 3 1 2 3]
1 2 3 1 2 3 1 2 3
into
x = [1 2 3; 1 2 3; 1 2 3]
1 2 3
1 2 3
1 2 3
I would like to apply this to a case where I have a string with 10,000 entries and would like to turn that string into a 100 x 100 array.
Thanks for looking at my problem.

Respuesta aceptada

Teja Muppirala
Teja Muppirala el 14 de Mzo. de 2011
If what you are really asking is "how do I turn a row vector into a rectangular matrix" then you can use RESHAPE.
x = [3 5 2 6 8 22 3 0 9 8 2 5]
y = reshape(x,4,[])'
  1 comentario
Dominic Lawson
Dominic Lawson el 14 de Mzo. de 2011
thank you very much for the help

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings 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