필터 지우기
필터 지우기

Finding rows in matrix containing numbers from vector

조회 수: 9 (최근 30일)
Niels Brummerstedt
Niels Brummerstedt 2018년 11월 24일
답변: Bruno Luong 2018년 11월 24일
I have a matrix and a row vector
M = [1 4 3; 1 2 5; 3 2 1; 5 3 4; 2 3 5];
A = M(1,:);
Now, I wish to find the indices of all rows in M containing at least two of the values in A. As such, the desired output is
index = [1; 3; 4];
How would I do that?

채택된 답변

Bruno Luong
Bruno Luong 2018년 11월 24일
find(sum(ismember(M,A),2)>=2)

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by