Effacer les filtres
Effacer les filtres

Comparing two arrays of different length

102 vues (au cours des 30 derniers jours)
Majbah
Majbah le 17 Nov 2014
Commenté : Josep Llobet le 5 Oct 2021
Hi,
I have two arrays like, A=[11 11 2 3; 5 2 6 9] and B=[11 3; 2 9]. I want to know the indices of array A where the column of B is equal to column of A. In this case, the indices are [2 4].
How can I do that?
Thanks in Advance.

Réponse acceptée

Giorgos Papakonstantinou
Giorgos Papakonstantinou le 17 Nov 2014
You could this to find it:
idx = ismember(A', B', 'rows');
c = 1:size(A, 2);
d = c(idx); % is your answer
  2 commentaires
Majbah
Majbah le 17 Nov 2014
Thanks!
Josep Llobet
Josep Llobet le 5 Oct 2021
indeed, maybe
ismember(0, unique(idx))
used with 0 (no-coincident) or 1 (coincident), may be useful.
Then combined with
length(unique(idx))
For to know about the totallity of coincidences

Connectez-vous pour commenter.

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 17 Nov 2014
A=[11 11 2 3; 5 2 6 9]
B=[11 3; 2 9]
idx=find(ismember(A',B','rows'))

Catégories

En savoir plus sur Logical 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