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

    %% Compare String Arrays
% Starting in R2016b, you can create string arrays using the |string|
% function, and compare them using |strcmp|.
s1 = string({'A', 'bc';
             'def', 'G'});
s2 = string({'B', 'c';
             'def', 'G'});

tf = strcmp(s1,s2)

%%
% You can compare and sort string arrays with relational operators, just as 
% you can with numeric arrays.
%
% Use |==| to determine which elements of two string arrays are equal.
s1 == s2

%%
% Use |<| to determine which elements of |s1| are less than the corresponding 
% elements of |s2| according to ASCII dictionary order.
s1 < s2

%%
% Text processing functions (such as |strfind| and |regexp|) accept string 
% arrays as inputs, but other functions (for example, |addpath|) do not.