File Exchange

image thumbnail


version (152 KB) by Oleg Komarov
Ismember with reduced memory footprint through block processing


Updated 17 Aug 2015

GitHub view license on GitHub

Applies ismember with flexible (reduced) memory footprint as shown in the snapshot.
If you are working with large datasets and ismember eats up completely the RAM, starts swapping on disk, freezes your pc, and causes lots of frustration, you might then want to split the task. This is what ismemberb() does for you, with equivalent results to ismember() applied to the whole dataset.

The syntax:
Basically, the same as in ismember() with the additional ability to specify in how many sub-blocks to process the inputs.


% Run unit tests
ismemberb unit

% Default use
A = randi(100,[1e7,1]);
B = randi(100,[1e7,1]);

% Custom block split
ismemberb(A,B, [2,3])

% Stress test vs ismember()
A = table(randi(1e6,[3e7,1]),randi(1e6,[3e7,1]));
B = table(randi(1e6,[3e7,1]),randi(1e6,[3e7,1]));
[idx1,pos1] = ismember(A,B);
[idx2,pos2] = ismemberb(A,B);

Check and report new issues to

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor