Dear maintainers,
I discovered a different behaviour between Octave and Matlab for the
function ismember when the option 'rows' is given and one of the two
arguments is empty.
In Matlab:
>> ismember(ones(2),[],'rows')
ans =
0
0
>> ismember([],ones(2),'rows')
ans =
Empty matrix: 0-by-1
>> ismember([],[],'rows')
ans =
Empty matrix: 0-by-1
Although I don't completely understand this behaviour, I enclosed a patch
(against 3.2.3) which reproduces it.
Changelog
2009-10-16 Marco Caliari <
marco.caliari@...>
* ismember.m: Fix behaviour for empty arguments.
Marco
[ismember.m.patch]
--- ismember.m.orig 2009-10-16 10:33:32.000000000 +0200
+++ ismember.m 2009-10-16 10:27:54.000000000 +0200
@@ -95,6 +95,12 @@
endif
endfor
tf = logical (a_idx);
+ elseif (strcmpi (rows_opt, "rows") && isempty(s))
+ tf = false(size(a,1),1);
+ a_idx = false(size(a,1),1);
+ elseif (strcmpi (rows_opt, "rows") && isempty(a))
+ tf = zeros(0,1);
+ a_idx = zeros(0,1);
elseif (strcmpi (rows_opt, "rows"))
error ("ismember: with 'rows' both sets must be matrices with an equal number of columns");
else