如何在两个单元格中找到共同元素的索引?
谢谢.
例如:
cell1= {
A
B
C
D
E
f
}
cell2= {
g
h
f
D
i
l
m
n
}
Run Code Online (Sandbox Code Playgroud)
例如,cell2中的D和f的返回索引具有3和4索引.
ans=
0
0
0
4
0
3
Run Code Online (Sandbox Code Playgroud)
您可以ismember为此目的使用第二个输出参数:
[~, index] = ismember(cell1, cell2);
Run Code Online (Sandbox Code Playgroud)