File Exchange

image thumbnail

Set functions with multiple inputs

version (35.5 KB) by Oleg Komarov
Intersectm, ismemberm, setdiffm, setxorm, unionm with multiple inputs. Ex: intersectm(a,b,c,…).

1 Download

Updated 06 Aug 2010

View Version History

View License

Have you ever tried to find the common elements/rows to more than two sets without using a loop?

Now you can with multiple-input set functions: Intersectm, ismemberm, setdiffm, setxorm, unionm.

Brief syntax example:
- intersectm(a,b,c,d,....)
- intersectm(a,b,c,d,...,'rows')

These functions are substantially wrappers of ismember/ismemberm (like the original two-input ones with the exception of ismember).

For details see help.
For examples see the attached documentation.

Comments/suggestions/error reports are welcome.

Cite As

Oleg Komarov (2021). Set functions with multiple inputs (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

J. Alex Lee

I know this is a pretty old submission, but...The stated expected behavior of "setxorm", "returns values that are not in the intersection of A, B, C, ...", seems odd to me (although it is clear and seems to do what it says)...wouldn't you rather want it to return the values that are unique across A, B, C, etc.? So I would expect setxorm([1,2,3] , [2,3,4] , [3,4,5]) to return the values [1,5], not [1,2,4,5]. Of course, I guess xor is not really defined for non-binary decisions so perhaps both choices are valid and the issue is moot. In 2020, ismemberm seems to be broken because ismember now does not like to receive [] as a flag. Anyway, thank you for the submission! It has been instructive to study.


really nice work. It's amazing. Hopefully it can be faster in the future.

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!