Corresponding values between two matrices

조회 수: 2 (최근 30일)
HB
HB 2019년 12월 12일
답변: Fangjun Jiang 2019년 12월 12일
Hello,
I have two matrices of different sizes. Please see attached .mat files containing the matrices. Matrix A = [3168x2] and matrix B = [14x1].
The 14 values contained in the first column of matrix B are contained somewhere in the second column of matrix A. I need to identify which rows in A are these valinues contained and also extract the values contained in the first column for these rows.
Any suggestions?
Thanks in advance.

채택된 답변

Fangjun Jiang
Fangjun Jiang 2019년 12월 12일
index=ismember(A(:,2),B(:,1));
A(index,1)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by