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

    %% Cell Array of Character Vectors with Trailing White Space  
% Create a cell array of character vectors, |A|. 
A = {'dog','cat','fish','horse'};  

%% 
% Create a cell array of character vectors, |B|, where some of the vectors
% have trailing white space.
B = {'dog ','cat','fish ','horse'};  

%% 
% Find the character vectors in |A| that are not in |B|. 
[C,ia] = setdiff(A,B) 

%%
% |setdiff| treats trailing white space in cell arrays of character vectors
% as distinct characters.