"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gkp82g$b6k$1@fred.mathworks.com>...
> "Pr B" <pb2297@columbia.edu> wrote in message <gkp64i$jeu$1@fred.mathworks.com>...
> > hi all,
> >
> > i have a list of numbers as follows (list1):
> >
> > 22
> > 26
> > 51
> > 4
> > 740
> > ...
> >
> > and a two column list of numbers as follows (list2):
> >
> > 1 13
> > 4 9
> > 22 26
> > 33 740
> > 55 1234
> >
> > the task i want to accomplish is as follows:
> > if a number from list1 is found in a row in list2, i would like to remove that row from list2. in the above example the numbers 22, 26, 4, and 740 are found in both columns of list2 and i would like to remove rows 2, 3, and 4 of list2. how would i do this in a short matlab script?
> >
> > thanks!
>
> tf = reshape(~ismember(list2(:),list1),[],2);
> list2 = list2(tf(:,1)&tf(:,2));
>
> Roger Stafford
You can do without the reshape:
L1 = [22 ; 26 ; 51 ; 4 ; 740]
L2 = [1 13
4 9
22 26
33 740
55 1234] ;
L2(any(ismember(L2,L1),2),:) = []
hth
Jos
