Re: intersection for long list of cells



Chris schreef:
Hi all, I have two long lists of strings in cells (each 25K entries long) and I'd like to find the indices of entries that are common between both lists.

I'm hoping to find a faster way of doing this than an individual search (which takes way to long given the size of the lists)

Thanks!

Maybe you can have a look at the binary tree object named BTree in the GSTools toolbox. You can find it on the matlab file exchange server:

http://tinyurl.com/2f8cll

You can use something like
tree1=BTree(list1);
tree2=BTree(list2);
tmp = intersect(unique(list1), unique(list2))
for i=1:length(tmp)
res1=getitem(tree1, tmp{i});
res2=getitem(tree2, tmp{i});
positions{i,1} = cat(1,res1.itemvalues{:});
positions{i,2} = cat(1,res2.itemvalues{:});
end


The result is found in positions and this solution should work with stringlists, numeric vectors and 1D cell arrays with both numbers and strings.

Regards
Kris
.



Relevant Pages

  • Re: intersection for long list of cells
    ... entries that are common between both lists. ... Intersect doesn't operate on cells. ... lists of strings in cells (each 25K entries long) and I'd ...
    (comp.soft-sys.matlab)
  • P words in EDICT
    ... that the other 85,000 entries. ... largly by the presence of those words on study lists, ... 1M hits on Google (with the Japanese language filter set.) ...
    (sci.lang.japan)
  • Re: intersection for long list of cells
    ... entries that are common between both lists. ...
    (comp.soft-sys.matlab)
  • intersection for long list of cells
    ... I have two long lists of strings in cells (each ... entries that are common between both lists. ...
    (comp.soft-sys.matlab)
  • Re: The Anime Primer "Pre-Approved List"
    ... but aren't yet in the Primer. ... only write entries for shows you like enough to recommend to ... quarterly anime review lists, three stars on Manbow Papa's quarterly ... Ouran High School Host Club ...
    (rec.arts.anime.fandom)

Loading