MEMBERSHIP

Membership of elements of one array in another.
1.8K Downloads
Updated 7 Jun 2005

No License

MEMBERSHIP counts membership of elements of one array in another.

C = MEMBERSHIP(A,B) for the array A returns an array of the same size as A containing the number of instances of the elements of A in the array B. A and B can be character arrays or cell arrays of strings.

Examples:
membership(1:6,pascal(3)) returns [5 1 2 0 0 1]
membership('MASK','MISSISSIPI') retruns [1 0 4 0]
membership({'john','gul';'sim','ku'},{'sim','gul','kid','gul'}) returns
[0 2;1 0]

See also FREQTABLE, ISMEMBER

Cite As

Mukhtar Ullah (2024). MEMBERSHIP (https://www.mathworks.com/matlabcentral/fileexchange/7796-membership), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Characters and Strings in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0.0

a check included