Matlab,在两个数组中找到共同值 [英] Matlab, finding common values in two array

查看:11
本文介绍了Matlab,在两个数组中找到共同值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I want to find common values in two arrays(For example if A=[1 2 3 4 5 6] and B=[9 8 7 6 3 1 2] the result is ans=[1 2 3 6]).Is there any method without using loop?

Thanks

解决方案

use intersect(A,B) to get the answer.

Another option is to use ismember, for example A(ismember(A,B)).

这篇关于Matlab,在两个数组中找到共同值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆