www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/CountOccurrencesOfPatternInStringArrayExample.m

    %% Count Occurrences of Pattern in String Array
% Count the number of occurrences of the word |red| in the string array.
str = string({'red green red red blue blue green';
              'green red blue green green blue'})

%%
A = count(str,'red')