|
"Dave Brackett" <davebrackett@hotmail.com> wrote in message <h59fvc$dqn$1@fred.mathworks.com>...
> Hi, i'm trying to replace 'ismember' with 'ismembc' to speed up the operation (as mentioned here
> http://undocumentedmatlab.com/blog/tag/ismember/) . However, I used 'ismember' with the 'rows' argument specified and can't see how to replicate this using 'ismembc'. Does someone know how to do this please?
Look inside the ismember code (type 'edit ismember' in the Matlab Command Window) and see that it pre-processes the data rows, before recursively re-invoking the regular ismember() function (which in turn uses ismembc).
If you're certain about all the conditioned I mentioned in the post that you linked above (i.e., only sorted non-sparse non-NaN values), then you can simply take the relevant code segment from the ismember.m code (the section after the else 'rows') and replace the recursive call to ismember() with a call to ismembc(). You can use Matlab's built-in profiler to see a code-coverage of ismember.m, showing you which lines got executed for your specific inputs - these are the lines you should copy.
I reiterate my warning - unless you're positive about the well-behavior of the input data, better stick with Matlab's ismember(), which handles edge cases and does several sanity checks. A run-time failure due to a mis-behaving data point may not be worth the performance boost of using ismembc.
Yair Altman
http://UndocumentedMatlab.com
|