Can you set the tolerance for ismembertol as a percentage?
Mostrar comentarios más antiguos
Is there a way to use the function ismembertol and set the tolerance as a percentage of the dataset?
Respuestas (2)
the cyclist
el 6 de Mayo de 2015
0 votos
By default, the tolerance is a fraction (1.e-12 for double-precision input) of the maximum absolute value of the inputs.
2 comentarios
JChemPhD
el 6 de Mayo de 2015
the cyclist
el 6 de Mayo de 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
el 6 de Mayo de 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)
Categorías
Más información sobre Multidimensional Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!