【发布时间】:2012-03-14 18:50:12
【问题描述】:
我正在尝试在 MATLAB 的元胞数组中查找子字符串出现的位置。下面的代码有效,但相当难看。在我看来应该有一个更简单的解决方案。
cellArray = [{'these'} 'are' 'some' 'nicewords' 'and' 'some' 'morewords'];
wordPlaces = cellfun(@length,strfind(cellArray,'words'));
wordPlaces = find(wordPlaces); % Word places is the locations.
cellArray(wordPlaces);
【问题讨论】: