- 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
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Stephen23
2022 年 1 月 25 日
編集済み: Stephen23
2022 年 1 月 25 日
"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:
その他の回答 (1 件)
Voss
2022 年 1 月 25 日
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)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!