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 visualización (últimos 30 días)
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 comentario
Sulaymon Eshkabilov
Sulaymon Eshkabilov el 17 de Oct. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 17 de Oct. de 2019
Editada: KALYAN ACHARJYA el 17 de Oct. de 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)

Más respuestas (0)

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by