필터 지우기
필터 지우기

finding values common to 3 different single-column matrices

조회 수: 29 (최근 30일)
Michael
Michael 2011년 5월 19일
댓글: Sibel Akyuz 2022년 11월 1일
basically i have 3 different matrices (A, B, and C). Each one contains different numbers and is of a different length. However, there are numbers common to all 3 of them. I need to be able to create an output that lists all numbers that are common to all 3 matrices.
For example,
A = [2; 5; 7; 9; 13];
B = [5; 13; 17];
C = [1; 2; 3; 5; 10; 13; 15; 16];
Thus, the common numbers in this case are 5 and 13.
Any idea how to compare the three and find these values?

답변 (3개)

Andrei Bobrov
Andrei Bobrov 2011년 5월 19일
intersect(intersect(A,B),C)

Oleg Komarov
Oleg Komarov 2011년 5월 19일
Out = intersectm(A,B,C)

Sean de Wolski
Sean de Wolski 2011년 5월 19일
C(ismember(C,A(ismember(A,B))))
  댓글 수: 1
Matt Fig
Matt Fig 2011년 5월 19일
This approach can return repeated values if the elements of the individual vectors aren't unique.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by