Duplicate names in one cell column
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(2 个)
Yatin
2013-10-15
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.
0 个评论
Jan
2013-10-15
编辑:Jan
2013-10-16
duplicateName = (numel(unique(C(:, index))) == size(C, 1))
[EDITED: Parenthesis fixed]
2 个评论
Jan
2013-10-16
In your question you wrote:
I have a cell that contain several columns among them one text column
Then index is the index of the column, which contains the text. If C is this column already, use:
numel(unique(C)) == size(C, 1)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!