Concatenate two cells into another

1 次查看(过去 30 天)
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?

采纳的回答

Yona
Yona 2014-12-30
do you try to use strcat?
It allow you to concatenate two cells.
Ce = {'Aluno', '41563'};
C3 = strcat(Ce{1}(1),Ce{2});
  2 个评论
António
António 2014-12-30
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 2015-1-1
编辑:Yona 2015-1-1
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})];

请先登录,再进行评论。

更多回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by