Mercurial > hg > octave-shane
changeset 9733:aab4f2aa9ed9
make ismember more matlab compatible
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 16 Oct 2009 13:13:36 +0200 |
parents | b4fdfee405b5 |
children | 1a9508872af0 |
files | scripts/set/ismember.m |
diffstat | 1 files changed, 14 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/set/ismember.m +++ b/scripts/set/ismember.m @@ -133,20 +133,24 @@ elseif (! ischar (a) && ! isnumeric (a)) error ("ismember: input arguments must be arrays, cell arrays, or strings"); endif - if (columns (a) != columns (s)) + if (isempty (a) || isempty (c)) + tf = false (rows (a), 1); + a_idx = zeros (rows (a), 1); + elseif (columns (a) != columns (s)) error ("ismember: number of columns must match"); - endif + else - ## FIXME: lookup does not support "rows", so we just use unique. - [xx, ii, jj] = unique ([a; s], "rows", "last"); - na = rows (a); - jj = ii(jj(1:na)); - tf = jj > na; + ## FIXME: lookup does not support "rows", so we just use unique. + [xx, ii, jj] = unique ([a; s], "rows", "last"); + na = rows (a); + jj = ii(jj(1:na)); + tf = jj > na; - if (nargout > 1) - a_idx = max (0, jj - na); + if (nargout > 1) + a_idx = max (0, jj - na); + endif + endif - else print_usage (); endif