%% Set Members in Presence of Numerical Error
% Create a vector x. Obtain a second vector y by transforming and untransforming x. This transformation introduces round-off differences in y.

x = (1:6)'*pi;
y = 10.^log10(x);

%
% Verify that x and y are not identical by taking the difference.

x-y

%
% Use ismember to find the elements of x that are in y. The ismember function performs exact comparisons and determines that some of the matrix elements in x are not members of y.

lia = ismember(x,y)

%
% Use ismembertol to perform the comparison using a small tolerance. ismembertol treats elements that are within tolerance as equal and determines that all of the elements in x are members of y.

LIA = ismembertol(x,y)

% Copyright 2015 The MathWorks, Inc.