www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/FindTextInStringExample.m
%% Search for Single Pattern % Create a string array that contains names. Determine which strings contain |Paul|. str = string({'Mary Ann Jones','Paul Jay Burns','John Paul Smith'}) %% % Return a logical array where the position of each element equal to |1| % corresponds to the position of a string in |str| that contains |Paul|. pattern = 'Paul'; TF = contains(str,pattern) %% % Display the strings that contain |Paul|. Index back into |str| using |TF|. str(TF)