Effacer les filtres
Effacer les filtres

Finding rows in matrix containing numbers from vector

9 vues (au cours des 30 derniers jours)
Niels Brummerstedt
Niels Brummerstedt le 24 Nov 2018
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?

Réponse acceptée

Bruno Luong
Bruno Luong le 24 Nov 2018
find(sum(ismember(M,A),2)>=2)

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by