2017-10-12 101 views
1

我只需要保留元素数组中第n个元素后面的元素。单元格数组文本操作

例子:

cell_in = {'test string no (1)'; 
      'test string no (2)'; 
      'test string no (3)'} 

,我需要得到这样的结果:

cell_out = {'no (1)'; 
      'no (2)'; 
      'no (3)'} 

我已经试过这失败的情况如下:

cell_out = cell_in{:}(13:end) 

有没有一种办法解决这个问题,也许使用cellfun

+0

欢迎堆栈溢出! –

回答

1

您不能直接将索引应用于所有单元格的内容。

达到你想要的一种方式是通过anonymous function使用cellfun到所需的索引适用于所有细胞的内容:

cell_out = cellfun(@(c) c(13:end), cell_in, 'UniformOutput', false); 
+0

这就是我正在寻找的,非常感谢路易斯! –