low speed of 'ismember' function
8 views (last 30 days)
hi. in my code there is a for loop like the following:
This loop is repeated several thousand times. 'ismember' function is very slow. So that most of the runtime for 'ismember' function lost. Is there any alternative to this?
David Sanchez on 29 Aug 2014
Depending on your data, you might try to code your own function avoiding some conditions and calls to sub-functions within the ismember function.
You can take a look at ismember code with:
and try to make it easier.
Titus Edelhofer on 29 Aug 2014
does "Vector1" and "Vector2" changes in every iteration? Often you see something like
v = ismember(x(i), y);
% do something
which can be changed to
vAll = ismember(x, y);
% now do something with vAll(i)