Eliminating common elements across multiple arrays
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i have data like-
A1 x A2 y
1 1.2 1 1.3
3 1.3 2 1.6
4 1.4 3 1.5
5 1.5 4 1.4
8 1.4 6 1.4
9 1.7 7 1.7
11 1.6 8 1.5
12 1.3 9 1.7
14 1.6 10 1.2
15 1.8 12 1.3
13 1.2
14 1.5
15 1.9
and i want the output in which both are common like-
A x y
1 1.2 1.3
3 1.3 1.5
4 1.4 1.4
8 1.4 1.5
9 1.7 1.7
12 1.3 1.3
14 1.6 1.5
15 1.8 1.9
0 commentaires
Réponses (1)
Stephen23
le 5 Déc 2016
Modifié(e) : Stephen23
le 5 Déc 2016
Ax = [1;3;4;5;8;9;11;12;14;15];
x = [1.2;1.3;1.4;1.5;1.4;1.7;1.6;1.3;1.6;1.8];
Ay = [;1;2;3;4;6;7;8;9;10;12;13;14;15];
y = [1.3;1.6;1.5;1.4;1.4;1.7;1.5;1.7;1.2;1.3;1.2;1.5;1.9];
[A,idx,idy] = intersect(Ax,Ay);
xn = x(idx);
yn = y(idy);
which gives:
>> [A,xn,yn]
ans =
1 1.2000 1.3000
3 1.3000 1.5000
4 1.4000 1.4000
8 1.4000 1.5000
9 1.7000 1.7000
12 1.3000 1.3000
14 1.6000 1.5000
15 1.8000 1.9000
2 commentaires
Stephen23
le 7 Déc 2016
@AKHILESH KUMAR: I am glad that it worked. Please accept my answer if it helped you.
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!