关闭。这个问题需要details or clarity .它目前不接受答案。
想改善这个问题吗?通过 editing this post 添加详细信息并澄清问题.
6年前关闭。
Improve this question
我在 Matlab 中有一个大的字符串元胞数组。我需要在这个数组中找到重复字符串的索引。也就是说,我期望的输出是在字符串元胞数组中出现两次或更多次的字符串索引数组。
我怎样才能做到这一点?
最佳答案
这可以通过 unique 来完成:
strings = {'some' 'strings' 'with' 'with' 'duplicate' 'strings' 'strings'};
[~, uniqueIdx] =unique(strings) % Find the indices of the unique strings
duplicates = strings % Copy the original into a duplicate array
duplicates(uniqueIdx) = [] % remove the unique strings, anything left is a duplicate
duplicates = unique(duplicates) % find the unique duplicates
关于matlab - 在字符串数组中查找重复的条目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26347457/