2
我想找到兩個數組的共同值(例如,如果A = [1 2 3 4 5 6]且B = [9 8 7 6 3 1 2],結果是ans = [1 2 3 6])。是否有沒有使用循環的方法?Matlab,找到兩個數組中的常見值
感謝
我想找到兩個數組的共同值(例如,如果A = [1 2 3 4 5 6]且B = [9 8 7 6 3 1 2],結果是ans = [1 2 3 6])。是否有沒有使用循環的方法?Matlab,找到兩個數組中的常見值
感謝
使用intersect(A,B)
得到答案。
另一種選擇是使用ismember
,例如A(ismember(A,B))
。
感謝您的回答。 – Fatime 2013-05-11 05:47:14