Why the 'ismembertol' function fails on this 5 lines code?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Tried to run this code
bb = [20 10
NaN NaN];
aa = [20 8
20 10];
[LIA,LOCB] = ismembertol(aa, bb,'ByRows', true);
But the following unexpected result was acquired.
LIA =
2×1 logical array
0
0
Then, if I revise matrix 'aa', and run the following code again, reasonable result can be get.
bb = [20 10
NaN NaN];
aa = [20 10];
[LIA,LOCB] = ismembertol(aa, bb,'ByRows', true);
>> LIA =
logical
1
Any corrections? Thank you!
Jie
2 Commenti
Guillaume
il 5 Dic 2019
Modificato: Guillaume
il 5 Dic 2019
I'd say you've hit a bug in ismembertol. At the very least it doesn't behave as describe in the documentation.
The problem appears to be caused by the NaNs. So, to work around the problem you could remove nan rows.
You should raise a bug report with Mathworks.
Unfortunately, we can't really investigate the problem ourselves since ismembertol is a built-in function.
edit: I've raised a bug report, you should still do that if you want to be informed about the resolution
Risposte (1)
Guillaume
il 9 Dic 2019
As per my comment, I raised a service request with Mathworks and they have confirmed that it is indeed a bug.
As the bug is not present when 'ByRows' is false (the default), they recommend to use:
all(ismembertol(aa, bb), 2)
instead of
ismembertol(aa, bb, 'ByRows', true)
This works as long as you don't need LocB. If you do need LocB, then I recommend you remove the NaNs from the arrays.
0 Commenti
Vedere anche
Categorie
Scopri di più su Variables in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!