Re: intersection for long list of cells
- From: Kris De Gussem <Kris.DeGussem@xxxxxxxx>
- Date: Wed, 16 Apr 2008 16:12:13 +0200
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
.
- References:
- intersection for long list of cells
- From: Chris
- intersection for long list of cells
- Prev by Date: Mouse Track
- Next by Date: Re: Fitting Nonlinear Complex Data(How do you do this?)
- Previous by thread: Re: intersection for long list of cells
- Next by thread: decimal to binary conversion in Simulink
- Index(es):
Relevant Pages
|
Loading