找到位置并确定具有相同位置的另一个阵列的相应值 [英] Find the location and determine the corresponding value of another array having the same location of one array
本文介绍了找到位置并确定具有相同位置的另一个阵列的相应值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
a = [5 8 1 2 6 7 1 4 2 3 7 8];
b = [7 6 3 1 5 4 2 0 1 8 9 4];
然后
$ p $对应于一个矩阵,d应该是a
值。如何找到这个值?解决方案
arrayfun(@(x)b(find(a == x,1,'first')),a1)
pre>
If
a=[5 8 1 2 6 7 1 4 2 3 7 8]; b=[7 6 3 1 5 4 2 0 1 8 9 4];
then
a1=[1 7 3]
corresponds to a matrix and d should be
[3 4 8]
d
is the exact location of the correspondinga
value. How do I find this value?解决方案As a one-liner:
arrayfun(@(x) b(find(a == x, 1, 'first')), a1)
这篇关于找到位置并确定具有相同位置的另一个阵列的相应值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文