Duplicate names in one cell column
Show older comments
Hi,
I have a cell that contain several columns among them one text column (e.g., Person names). How can I check that the there is no duplicate names inside this column (If there is a duplicate names just assign duplicateName=true).
Thanks
Answers (2)
Yatin
on 15 Oct 2013
Hi,
You can use the " hist " functions and the unique functions to determine if there are any duplicate values in your columns. Below is a sample code snippet:
arr = [5 3 1 5 6];
u = unique(arr);
n = hist(arr, u);
result = arr(n > 1);
Hope this helps.
duplicateName = (numel(unique(C(:, index))) == size(C, 1))
[EDITED: Parenthesis fixed]
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!