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 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Catalytic Kys
am 17 Okt. 2019
Bearbeitet: KALYAN ACHARJYA
am 17 Okt. 2019
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 Kommentar
Sulaymon Eshkabilov
am 17 Okt. 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.
Akzeptierte Antwort
KALYAN ACHARJYA
am 17 Okt. 2019
Bearbeitet: KALYAN ACHARJYA
am 17 Okt. 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)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!