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

前端 未结 3 760
情深已故
情深已故 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:55

    You can do that using cellfun:

    cellfun(@(x,y) [x, ' ', y], A, B, 'UniformOutput', false)
    
    ans = 
    {
      [1,1] = hello Ben
      [2,1] = hi Karen
      [3,1] = hey Lisa
    }
    

提交回复
热议问题