Matlab "Find"命令用于获取值列表?如何找到列表中给定值的索引值?

标签 matlab list-comprehension

find(a==100) 适用于值,但不适用于值列表。在Python中,我会使用[find(a==cc) for cc in codomain]样式的列表理解来完成此操作,其中find是Matlab的查找。

示例

Input

>> a=[100,2,333,4,50,6,700];
>> codomain=[100,333,700];

Intended output: find the indices for the values in codomain, any command to do this?

[1,3,7]

最佳答案

您正在寻找的功能是

 ismember

关于Matlab "Find"命令用于获取值列表?如何找到列表中给定值的索引值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21024012/

相关文章:

matlab - 使用蒙特卡罗方法将矩阵元素扰动到其标称值周围约 10%

java - 如何通过 MATLAB Builder JA 访问构建的 jar 文件中保存在 .mat 文件中的变量?

matlab - 是否可以在 MATLAB 对象之间共享数据,例如查找表?

python - 元素出现两次的列表理解

python - 列出来自 Python 调试器的理解范围错误

Python3 : Matching elements between two lists based upon substrings

python - 使用 python 中的列表理解来减少

Matlab递减矩阵对角线

matlab从矩阵中获取数据,数据行和列索引存储在数组中

python - 如何使用带有条件表达式的 Python 列表理解