How do I compare 'list' with 'out' to check where both values of a row for 'out' are equal to both values of a row for 'list'?

1 vue (au cours des 30 derniers jours)
clear;
close all;
clc;
list = [
50 74;
6 34;
147 162;
120 127;
98 127;
120 136;
53 68;
145 166;
95 106;
242 243;
222 250;
204 207;
69 79;
183 187;
198 201;
184 199;
223 245;
264 291;
100 121;
61 61;
232 247;
153 181;
197 216;
283 307;
194 199;
82 109;
10 25;
60 90;
256 271;
172 173;
];
M = sortrows(list);
out = M(sum(squeeze(any(M - permute(M,[3,2,1]) <= 0,2))) == 1:size(list,1),:);
  1 commentaire
Sulaymon Eshkabilov
Sulaymon Eshkabilov le 17 Oct 2019
Their sizes mismatch. in order to compare them one by one, they should be of the same size. Now list is 30-by-2 and out is 16-by-2.

Connectez-vous pour commenter.

Réponse acceptée

KALYAN ACHARJYA
KALYAN ACHARJYA le 17 Oct 2019
Modifié(e) : KALYAN ACHARJYA le 17 Oct 2019
idx=find(list==out);
You will get the all rows value, where "list" rows value equal to "out" rows elements.
As per the question, the list size is 30x2, whereas out size is 16x2, hence it can not be directly compare with differenent matrices having unequal sizes. Hence I have trimmed the "list" matrics (First 16 rows considerd) to show the result-
list = [50 74;6 34;147 162;120 127;98 127;120 136;53 68;145 166;95 106;242 243;222 250;204 207;69 79;
183 187;198 201;184 199;223 245;264 291;100 121;61 61;232 247;153 181;197 216;283 307;194 199;82 109;
10 25;60 90;256 271;172 173]
M=sortrows(list);
out = M(sum(squeeze(any(M - permute(M,[3,2,1]) <= 0,2))) == 1:size(list,1),:)
idx=find(list(1:16,:)==out)

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Programming 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!

Translated by