필터 지우기
필터 지우기

Finding elements common to both arrays

조회 수: 1 (최근 30일)
L'O.G.
L'O.G. 2022년 4월 20일
답변: Torsten 2022년 4월 20일
Given
A = [1 2 3 6 7 9 10];
B = [4 7 8 10];
How would I determine that 7 and 10 are common to both vectors?
find(ismember(A,B))
appears to return the index of A that has the number(s) shared with B, which is not quite what I want. I want to return the values 7 and 10. How do I do that? I have very large vectors, but here I'm giving a simple example.

채택된 답변

Torsten
Torsten 2022년 4월 20일
Use
v = intersect(A,B)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by