2017-10-12 103 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

這就是我正在尋找的,非常感謝路易斯! –