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

    %% Preserve Legacy Behavior of ismember
% Use the |'legacy'| flag to preserve the behavior of |ismember| from
% R2012b and prior releases in your code.

% Copyright 2015 The MathWorks, Inc.


%%
% Find the members of |B| with the current behavior.
A = [5 3 4 2]; 
B = [2 4 4 4 6 8];
[Lia1,Locb1] = ismember(A,B)

%%
% Find the members of |B|, and preserve the legacy behavior.
[Lia2,Locb2] = ismember(A,B,'legacy')