matlab - 在字符串数组中查找重复的条目?

标签 matlab

关闭。这个问题需要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/

相关文章:

matlab - 我怎样才能让我的堆栈溢出?

Matlab - 查找矩阵中的值

matlab - 计算 3d 结构中的中心线

matlab - 函数句柄的内存大小 - MATLAB

Python 数组求和与 MATLAB

matrix - 如何使用 m 文件将多个计算输出为矩阵?

matlab - 在 MATLAB 中查找变量的小数位数

matlab - 如何为不同的间隔绘制不同颜色的函数?

java - 读取 .pgm 图像时在 Java 和 Matlab 之间具有不同的值

arrays - 在 Matlab 中将数组映射到逻辑数组