Borrar filtros
Borrar filtros

Concatenate two cells into another

1 visualización (últimos 30 días)
António
António el 30 de Dic. de 2014
Editada: Yona el 1 de En. de 2015
I have a cell with 'Aluno' and other cell with '41563'and i need to have another one with 'A41563'. How can i concatenate the first two cells to get the last one?

Respuesta aceptada

Yona
Yona el 30 de Dic. de 2014
do you try to use strcat?
It allow you to concatenate two cells.
Ce = {'Aluno', '41563'};
C3 = strcat(Ce{1}(1),Ce{2});
  2 comentarios
António
António el 30 de Dic. de 2014
It is parcially wright. The last cell gets the 'A' from 'Aluno' but did't shows the number from the other cell. Can it be caused because i'm using it to write in a table?
Yona
Yona el 1 de En. de 2015
Editada: Yona el 1 de En. de 2015
no, it probably because the number you have is a number not a string.
try:
C3 = strcat(Ce{1}(1),num2str(Ce{2}));
or:
C3 = [Ce{1} num2str(Ce{2})];

Iniciar sesión para comentar.

Más respuestas (1)

Ilham Hardy
Ilham Hardy el 30 de Dic. de 2014
Another way is,
Ce = {'Aluno', '41563'};
C3 = [Ce{1} Ce{2}];
Mind the curly brackets {} !

Categorías

Más información sobre Creating and Concatenating Matrices 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