Concatenate two cell arrays of strings with a space in between?

前端 未结 3 765
情深已故
情深已故 2021-01-14 16:02

How can I concatenate:

A = {\'hello\'; \'hi\'; \'hey\'}

with

B = {\'Ben\'; \'Karen\'; \'Lisa\'}

with a

3条回答
  •  既然无缘
    2021-01-14 16:53

    You can use strcat(), although it performs a loop:

    strcat(A,{' '}, B)
    

    where the blank is preserved by enclosing it within a cell.

    Alternatively, FEX:CStrCatStr is a mex routine which achieves a 10x speedup (depending on testing environment):

    CStrCatStr(A,' ', B)
    

提交回复
热议问题