match row column of matrix

1 vue (au cours des 30 derniers jours)
Tanmoyee Bhattacharya
Tanmoyee Bhattacharya le 5 Fév 2020
Modifié(e) : Guillaume le 5 Fév 2020
If I have one matrix
1 23
2 54
3 76
4 67
5 23
The other matrix
4
3
If there is way to get
If Iwant a matrix
4 67
3 76

Réponse acceptée

Guillaume
Guillaume le 5 Fév 2020
Modifié(e) : Guillaume le 5 Fév 2020
A = [1 23
2 54
3 76
4 67
5 23];
B = [4;3];
result = A(ismember(A(:, 1), B), :) %keep the rows of A whose 1st column is a member of B

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by