Can you set the tolerance for ismembertol as a percentage?
Show older comments
Is there a way to use the function ismembertol and set the tolerance as a percentage of the dataset?
Answers (2)
the cyclist
on 6 May 2015
0 votes
By default, the tolerance is a fraction (1.e-12 for double-precision input) of the maximum absolute value of the inputs.
2 Comments
JChemPhD
on 6 May 2015
the cyclist
on 6 May 2015
OK, well the documentation is pretty clear on the options you have there. If none of those options do what you need, then you'll just need to code it up yourself.
the cyclist
on 6 May 2015
Here is something that sounds close to what you mean. You'll need to adjust the tolerance criterion.
% Pretend data
A = [1 2 299.99];
B = [1.5 3.5 300];
% Define the tolerance as a fraction of each B value
Btol = B/1000;
% Find whether each value of A is near each value of B
A_near_each_B = bsxfun(@gt,A,B-Btol) & bsxfun(@lt,A,B+Btol);
% Find whether each value of A is near ANY value of B. (This is kinda like ismembertol.)
A_near_any_B = any(A_near_each_B)
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!