我的单元格数组中包含如下所示的字符串
a =
'one' 'two'
'three' 'four'
现在我将上面的单元格数组 a 分配给另一个单元格数组 b 第一个,第二个和第三个位置如下所示
b{1} =a;
b{2} =a;
b{3} =a;
现在我想将字符串X = '-h';
与 b 单元格数组的每一个字符串组合
我该怎么办?
示例输出
b =
{2x2 cell}
{2x2 cell}
{2x2 cell};
b{1} ={'one-h' 'two-h' ;'three-h' 'four-h'};
b{2} ={'one-h' 'two-h' ;'three-h' 'four-h'};
b{3} ={'one-h' 'two-h' ;'three-h' 'four-h'};
但是我将a值分配给b之后需要此输出,如步骤2(b{1} = a
...)和字符串 X 必须与 b 单元格结合使用仅限数组
答案 0 :(得分:1)
试试这个:
%// Using nested cellfun
b = cellfun(@(x) cellfun(@(y) strcat(y,'-h'),x,'Uni',0),b,'Uni',0);
<强>输出:强>
>> b{1}
ans =
'one-h' 'two-h'
'three-h' 'four-h'