I have a list of 100 random numbers 1-10:
numpoints = 100; gridnum = 10; grid_ind = randi(gridnum,[numpoints 1]); % 100 points in 10 random cells
and each of the 10 possible values has a corresponding list (of random length) of values, which are indexes to grid_ind:
for i=1:gridnum neighbgrids{i} = randi(numpoints,[randi(5) 1]); end
So far, so good. Now, I need to find the indexes for all elements in grid_ind which have the same values as in each cell list in neighbgrids. So I use:
for i=1:numpoints neighblist{i} = find(ismember(grid_ind,neighbgrids{grid_ind(i)})); end
But this turns out to be very slow. Is there a faster way to do this part?
Best Answer