Corresponding values between two matrices

2 Ansichten (letzte 30 Tage)
HB
HB am 12 Dez. 2019
Beantwortet: Fangjun Jiang am 12 Dez. 2019
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.

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 12 Dez. 2019
index=ismember(A(:,2),B(:,1));
A(index,1)

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by