- you provided a tol value of 10e-3, which is simpler written as 1e-2. Did you really mean 1e-3 ?
- perhaps you expect tol to be the tolerance used in the comparison. That is not the default behavior, but can be achieved very easily by reading the documentation and specifying DataScale = 1.
Question about using ismembertol function
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ali Sohrabi
am 25 Jan. 2022
Kommentiert: Ali Sohrabi
am 25 Jan. 2022
Hi there,
I have a question about using ismembertol function. I am working with this function, and now I am spotting out that something is going wrong with my calculation regarding this function. I show what is wrong in one small example.
Consider
A=[11538.0882247944, 21569.4133365453]
B=[ 11537.6120343925,21611.5704794796]
ismembertol(A,B, 10e-3,'ByRows',true)
I want to check whether A is a part of B or not? The result should show that A has not been found in B, but it says that it finds! Could you please help what I made a mistake here, or is it a bug in Matlab?
0 Kommentare
Akzeptierte Antwort
Stephen23
am 25 Jan. 2022
Bearbeitet: Stephen23
am 25 Jan. 2022
"The result should show that A has not been found in B...
You do not explain why you think that. I am guessing that you misunderstand the meaning of the third input.
Lets read the ISMEMBERTOL documentation, which describes the third input tol as: "Two values, u and v, are within tolerance if abs(u-v) <= tol*max(abs([A(:);B(:)]))". Now lets calculate this tolerance for your arrays:
tol = 10e-3;
A = [11538.0882247944, 21569.4133365453];
B = [11537.6120343925, 21611.5704794796];
T = tol*max(abs([A(:);B(:)]))
So we know that any values that are within 216.1157... of each other will be considered to be matching. Lets check how different your array values are:
A-B
abs(A-B)<T
So the values you are comparing differ by much less than 216.1157..., and so ISMEMBERTOL correctly identifies them as matching. So far ISMEMBERTOL is working exactly as documented. You have not explained anywhere why you think is it not.
Regarding the third input tol:
Weitere Antworten (1)
Voss
am 25 Jan. 2022
Note that 10e-3 = 1e-2. Maybe that is the problem
A=[11538.0882247944, 21569.4133365453]
B=[11537.6120343925, 21611.5704794796]
ismembertol(A,B,10e-3,'ByRows',true)
ismembertol(A,B, 1e-3,'ByRows',true)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!