www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/FindPatterninCellArrayofStringsExample.m
%% Find Pattern in Cell Array % Find the starting indices for occurrences of a pattern in a cell array % of character vectors. %% % Create a cell array of character vectors. str = {'How much wood would a woodchuck chuck'; 'if a woodchuck could chuck wood?'}; %% % Find the pattern |wood| in |str|. idx = strfind(str,'wood') %% % Examine the output cell array to find the instances of the pattern. idx{:,:} %% % The pattern |wood| occurs at indices 10 and 23 in the first character vector % and at indices 6 and 28 in the second character vector.