Borrar filtros
Borrar filtros

concatenate a cell array(string) and a double array numeric

24 visualizaciones (últimos 30 días)
yasmine
yasmine el 28 de Mzo. de 2012
i have 2 arrays:
x = {'tom' 'sara' 'bob'} y = [ 1 2 3 ; 3 4 5 ; 1 4 2]
how can i concatenate x and y vertically with a single array with x as header?
  1 comentario
Jan
Jan el 28 de Mzo. de 2012
This topic has been discussed already: http://www.mathworks.com/matlabcentral/answers/33087-how-to-combine-an-cell-array-and-a-double-array
Please do not double-post.

Iniciar sesión para comentar.

Respuestas (1)

Andrei Bobrov
Andrei Bobrov el 28 de Mzo. de 2012
out = [x;num2cell(y)];
  2 comentarios
yasmine
yasmine el 28 de Mzo. de 2012
is there a way where we can remove the inverted comma in the answer.
Jan
Jan el 28 de Mzo. de 2012
The quote characters are not part of the array, but inserted when printing to the command window only. They show, that the included characters are a string, e.g. to distinguish '9' from 9.

Iniciar sesión para comentar.

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