Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: ismember - getting wrong result
Date: Mon, 16 Mar 2009 12:41:14 +0000 (UTC)
Organization: Queen's University
Lines: 9
Message-ID: <gplhda$fm2$1@fred.mathworks.com>
References: <gpb180$5uv$1@fred.mathworks.com> <gpb1n2$851$1@fred.mathworks.com> <gplfbn$3sp$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1237207274 16066 172.30.248.38 (16 Mar 2009 12:41:14 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 16 Mar 2009 12:41:14 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 943450
Xref: news.mathworks.com comp.soft-sys.matlab:525189


For a concise, stripped-down alternative to ismember with a tolerance, you could use

function tf = ismem_tol(A, S, tol)
d = bsxfun(@minus, A(:), S(:)');
tf = any(abs(d) <= tol, 2);
tf = reshape(tf, size(A));


There's no 'rows' option or second output (which would be the index of the last nonzero column in each row of abs(d) <= tol), and I suppose it's not very memory efficient for large inputs, but it's short and simple.