Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <Steven_Lord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: ismember
Date: Thu, 14 Nov 2013 17:06:11 -0500
Organization: MathWorks
Lines: 46
Message-ID: <l63hgj$ehi$1@newscl01ah.mathworks.com>
References: <l5ujhm$et9$1@newscl01ah.mathworks.com> <l5ulh7$a14$1@newscl01ah.mathworks.com> <l5unmh$6b3$1@newscl01ah.mathworks.com> <l5uoiq$ghj$1@newscl01ah.mathworks.com> <l604i6$arn$1@newscl01ah.mathworks.com> <l61oll$f90$1@newscl01ah.mathworks.com> <l62nt2$mu0$1@newscl01ah.mathworks.com> <l633am$3cj$1@newscl01ah.mathworks.com> <l635fm$k88$1@speranza.aioe.org> <l6364l$bq4$1@newscl01ah.mathworks.com>
Reply-To: "Steven Lord" <Steven_Lord@mathworks.com>
NNTP-Posting-Host: ah-slord.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain;
	format=flowed;
	charset="UTF-8";
	reply-type=response
Content-Transfer-Encoding: 7bit
X-Trace: newscl01ah.mathworks.com 1384466771 14898 172.28.8.241 (14 Nov 2013 22:06:11 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 14 Nov 2013 22:06:11 +0000 (UTC)
In-Reply-To: <l6364l$bq4$1@newscl01ah.mathworks.com>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: news.mathworks.com comp.soft-sys.matlab:805299


"Jerry " <jerrycholo@gmail.com> wrote in message 
news:l6364l$bq4$1@newscl01ah.mathworks.com...
> You are right; based on D,
>
> D =
>
>     0 1 0 0 0 0 0
>     0 0 0 0 0 0 0
>     0 1 0 1 0 0 0
>     0 0 1 0 0 0 0
>     0 1 0 0 0 0 0
>
> I would expect to get this output which is X:
>
> X =
>
>    'rte' '345' '---' '---' 'rte' '345_rt' '---' 'ytr' '476' '543' '467' 
> 'ytr' '987_kj' '---' 'poi' '890' '343' '---' 'poi' '873_mn' '875_jh'
>    'uyt' '345' '---' '---' 'uyt' '234_io' '---'
> Thanks,
> Jerry

So you want the rows of R containing ANY of the strings in N? You were 
close.


% Find those elements in R that are in N
D = ismember(R, N)

% Ask if ANY of the elements in D are true, operating along the rows
% Since D has the same number of rows as R, doesThisRowContainStringsFromN
% will have that same number of rows
doesThisRowContainStringsFromN = any(D, 2)

% Use the true values from doesThisRowContainStringsFromN to extract the
% corresponding rows of R
rowsOfRContainingAnyStringFromN = R(doesThisRowContainStringsFromN, :)


-- 
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on 
http://www.mathworks.com