Can you set the tolerance for ismembertol as a percentage?

Is there a way to use the function ismembertol and set the tolerance as a percentage of the dataset?

Answers (2)

By default, the tolerance is a fraction (1.e-12 for double-precision input) of the maximum absolute value of the inputs.
Read the documentation for ismembertol for details.

2 Comments

I guess what I need is a little more complicated. I need a fraction of every value the isamembertol command is comparing against.
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.

Sign in to comment.

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

Tags

Asked:

on 6 May 2015

Answered:

on 6 May 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!